-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for jwks_uri in the discovery endpoint
- Loading branch information
1 parent
b7cdcb2
commit c06db94
Showing
9 changed files
with
336 additions
and
105 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const { co } = require('core-async') | ||
const { error: { catchErrors, wrapErrors } } = require('puffy') | ||
|
||
const endpoint = 'certs' | ||
|
||
const TRACE_ON = process.env.LOG_LEVEL == 'trace' | ||
|
||
/** | ||
* Verifies that a token is valid and returns the claims associated with that token if it is valid. | ||
* | ||
* @param {Object} _ | ||
* @param {Object} eventHandlerStore | ||
* @param {Object} context.endpoints Object containing all the OIDC endpoints (pathname only) | ||
* @param {Request} context.req Express Request | ||
* @param {Response} context.res Express Response | ||
* @param {String} context.authorization HTTP Authorization header value (e.g., 'Bearer 12345') | ||
* | ||
* @yield {[Error]} output[0] Array of errors | ||
* @return {[JWK]} output[1].keys | ||
*/ | ||
const handler = (_, eventHandlerStore={}) => catchErrors(co(function *() { | ||
if (TRACE_ON) | ||
console.log('INFO - Request to get the JWK public keys') | ||
|
||
const errorMsg = 'Failed to get the JWK public keys' | ||
|
||
if (eventHandlerStore.get_jwks) { | ||
const [errors, jwks] = yield eventHandlerStore.get_jwks.exec() | ||
if (errors) | ||
throw wrapErrors(errorMsg, errors) | ||
|
||
return { keys:jwks } | ||
} else | ||
return { keys:[] } | ||
})) | ||
|
||
module.exports = { | ||
endpoint, | ||
handler | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters