Skip to content

Add JWK Set Endpoint #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jzheaux opened this issue Apr 3, 2020 · 12 comments
Closed

Add JWK Set Endpoint #2

jzheaux opened this issue Apr 3, 2020 · 12 comments
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@jzheaux
Copy link
Contributor

jzheaux commented Apr 3, 2020

It would be quite useful to support an endpoint that would issue a JWK Set. Resource servers could retrieve this JWK Set for the purpose of validating JWTs.

For this task, we will avoid providing any of our own abstractions. The result should have a Filter that works directly with Nimbus to produce an response that looks something like:

{
    "keys": [
        {
            "alg": "RS256",
            "e": "AQAB",
            "kid": "257f6a5828d1e4a3a6a03fcd1a2461db9593e624",
            "kty": "RSA",
            "n": "kXPOxGSWngQ6Q02jhaJfzSum2FaU5_6e6irUuiwZbgUjyN2Q1VYHwuxq2o-aHqUhNPqf2cyCf2HspYwKAbeK9gFXqScrGLPW5pcquOWOVYUzPw87lBGH2fSxCYH35eB14wfLmF_im8DLTtZsaJvMRbqBgikM8Km2UA9ozjfK6E8pWW91fIT-ZF4Qy5zDkT3yX8EnAIMOuXg43v4t03FwFTyF4D9IET2ri2_n2qDhWTgtxJ0FHk3wG2KXdJIIVy2kUCTzMcZKaamRgUExt3Mu_z-2eyny8b6IdLPEIGF51VCgHebPQXE5iZmLGyw6M_pCApGJUw5GpXi6imo3pOvLjQ",
            "use": "sig"
        },
        {
            "alg": "RS256",
            "e": "AQAB",
            "kid": "6fcf413224765156b48768a42fac06496a30ff5a",
            "kty": "RSA",
            "n": "1sUr077w2aaSnm08qFmuH1UON9e2n6vDNlUxm6WgM95n0_x1GwWTrhXtd_6U6x6R6m-50mVS_ki2BHZ9Fj3Y9W5zBww_TNyNLp4b1802gbXeGhVtQMcFQQ-hFne5HaTVTi1y6QNbu_3V1NW6nNAbpR_t79l1WzGiN4ilFiYFU0OVjk7isf7Dv3-6Trz9riHBExl34qhriu3x5pfipPT1rf4J6jMroJTEeU6L7zd9k_BwjNtptS8wAenYaK4FENR2gxvWWTX40i548Sh-3Ffprlu_9CZCswCkQCdhTq9lo3DbZYPEcW4aOLBEi3FfLiFm-DNDK_P_gBtNz8gW3VMQ2w",
            "use": "sig"
        }
    ]
}

The keys that are used can be generated at startup or be constants. The Filter might look something like this:

public class JwkSetEndpoint implements Filter {
    private final JWKSet jwks;

    public JwkSetEndpoint() {
        this.jwks = ...
    }

    public void doFilter(...) {
        if (requestMatches(request)) {
            // ... serialize jwks into a response
        } else {
            chain.doFilter ...
        }
    }
}

A Filter is a good candidate since this will play nicely with Spring Security down the road. The constructor may change in the future as other abstraction layers become clearer.

We should then have a test that asserts the endpoint works properly.

@rwinch rwinch added this to the 0.0.1 milestone Apr 9, 2020
@jgrandja jgrandja changed the title Add JWK Set URI Endpoint Add JWK Set Endpoint Apr 9, 2020
@ghost
Copy link

ghost commented Apr 16, 2020

Hello @jzheaux . If it's ok with you I'll try to implement this part.

@jgrandja
Copy link
Collaborator

Thanks for the offer @ovidiupopa91. Please go ahead and let us know if you have any questions.

@paurav-munshi
Copy link
Contributor

@jgrandja @jzheaux Since there are plans for creating authorize, token and jwks endpoints. should we also create an issue for adding well know uri ?

@paurav-munshi
Copy link
Contributor

Since there are plans for creating authorize, token and jwks endpoints. should we also create an issue for adding well know uri ?

It seems its already there #27 . Apologies for creating the confusion if any.

jbellmann added a commit to jbellmann/spring-authorization-server that referenced this issue Apr 18, 2020
jbellmann added a commit to jbellmann/spring-authorization-server that referenced this issue Apr 18, 2020
jbellmann added a commit to jbellmann/spring-authorization-server that referenced this issue Apr 18, 2020
@ghost
Copy link

ghost commented Apr 21, 2020

As @jbellmann already created a PR for this issue, I will stop working on it.

cc: @jgrandja

@ahoehma
Copy link

ahoehma commented Apr 21, 2020

@ovidiupopa91 do you work now for spring? ;)

@ghost
Copy link

ghost commented Apr 21, 2020

@ovidiupopa91 do you work now for spring? ;)

@ahoehma In my spare time :)

@jgrandja
Copy link
Collaborator

Apologies for this @ovidiupopa91. See comment.

I'm in the process of creating issues for the next set of tasks so there will be plenty of work in the backlog to choose from. Please keep an eye out on the new issues coming up this week and let me know which one you would like to take on.

@ghost
Copy link

ghost commented Apr 22, 2020

Apologies for this @ovidiupopa91. See comment.

I'm in the process of creating issues for the next set of tasks so there will be plenty of work in the backlog to choose from. Please keep an eye out on the new issues coming up this week and let me know which one you would like to take on.

@jgrandja no problem. Looking forward to the next set of tasks.

@andifalk
Copy link

andifalk commented Apr 23, 2020

A Filter is a good candidate since this will play nicely with Spring Security down the road. The constructor may change in the future as other abstraction layers become clearer.

@jgrandja I do not really get the point why this has to be implemented as a filter rather than a Controller (which usually is used for an HTTP endpoint)? A JWKS endpoint should be publicly available to resource servers so there is no need for spring security to secure anything here?

@anzap
Copy link

anzap commented Apr 23, 2020

A Filter is a good candidate since this will play nicely with Spring Security down the road. The constructor may change in the future as other abstraction layers become clearer.

@jgrandja I do not really get the point why this has to be implemented as a filter rather than a Controller (which usually is used for an HTTP endpoint)? A JWKS endpoint should be publicly available to resource servers so there is no need for spring security to secure anything here?

@andifalk check the discussion in issue #3 and specifically this comment from @jgrandja #3 (comment)
It is a long discussion, but the main gist of it is that providing filters would enable this project to be used as a library to enable Authorization Server capabilities in non Spring MVC apps.

@andifalk
Copy link

A Filter is a good candidate since this will play nicely with Spring Security down the road. The constructor may change in the future as other abstraction layers become clearer.

@jgrandja I do not really get the point why this has to be implemented as a filter rather than a Controller (which usually is used for an HTTP endpoint)? A JWKS endpoint should be publicly available to resource servers so there is no need for spring security to secure anything here?

@andifalk check the discussion in issue #3 and specifically this comment from @jgrandja #3 (comment)
It is a long discussion, but the main gist of it is that providing filters would enable this project to be used as a library to enable Authorization Server capabilities in non Spring MVC apps.

@anzap Ok, I was not aware of this discussion. It is very difficult to follow such important general discussions that happen in different unrelated github issues. So far I did not know that this project is targeted to implement a framework for implementing custom auth servers. Then I am fine with that filter approach.

jbellmann added a commit to jbellmann/spring-authorization-server that referenced this issue Apr 27, 2020
jbellmann added a commit to jbellmann/spring-authorization-server that referenced this issue Apr 27, 2020
jbellmann added a commit to jbellmann/spring-authorization-server that referenced this issue May 3, 2020
jbellmann added a commit to jbellmann/spring-authorization-server that referenced this issue May 3, 2020
jbellmann added a commit to jbellmann/spring-authorization-server that referenced this issue May 3, 2020
jbellmann added a commit to jbellmann/spring-authorization-server that referenced this issue May 3, 2020
jbellmann added a commit to jbellmann/spring-authorization-server that referenced this issue May 10, 2020
jbellmann added a commit to jbellmann/spring-authorization-server that referenced this issue May 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants