Skip to content
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

Implement JSON Web Key Set endpoints #51

Closed
maxmouchet opened this issue Apr 12, 2020 · 2 comments
Closed

Implement JSON Web Key Set endpoints #51

maxmouchet opened this issue Apr 12, 2020 · 2 comments
Labels
discussion enhancement New feature or request

Comments

@maxmouchet
Copy link
Contributor

maxmouchet commented Apr 12, 2020

@maxmouchet
Copy link
Contributor Author

@jrebecchi
Copy link
Member

jrebecchi commented May 9, 2020

If Krypton is set directly in express like below:

app.use(kryptonAuth());

The JSON Web Key Set endpoints are available at http://the-adress-of-krypton/.well-known/jwks.json.

If Krypton is set after a subroute in express like below:

app.use('auth', kryptonAuth());

The JSON Web Key Set endpoints are available at http://the-adress-of-krypton/auth/.well-known/jwks.json.

With that, you can easily verify the JWTs emitted by Krypton and set the decoded user data inside req.user using with jwks-rsa :

app.use(jwt({
  secret: jwksRsa.expressJwtSecret({
    cache: true,
    rateLimit: true,
    jwksRequestsPerMinute: 150,
    jwksUri: 'http://localhost:' + PORT + '/.well-known/jwks.json'
  }),
  algorithms: ['RS256']
}));

This example suppose that your client has included inside the HTTP authorization header the JWT as a bearer token.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants