mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
🐛 Fixed signing key identificaiton in JWKs
refs https://github.com/TryGhost/Team/issues/1640 - The signing key returned by `GET /ghost/.well-known/jwks.json` was missing an OPTIONAL `use: "sig"` attribute needed to identify it as a signing key in client libraries. E.g. pyton lib: "pyjwt" or node lib: "jwks-client" - More about the "use" attribute at RFC7515 - https://www.rfc-editor.org/rfc/rfc7515#section-4.1.4
This commit is contained in:
parent
ffb8b36fc8
commit
6cc0c2b76b
2 changed files with 16 additions and 2 deletions
|
@ -16,7 +16,20 @@ module.exports = function setupWellKnownApp() {
|
||||||
|
|
||||||
wellKnownApp.get('/jwks.json', async (req, res) => {
|
wellKnownApp.get('/jwks.json', async (req, res) => {
|
||||||
const jwks = await getSafePublicJWKS();
|
const jwks = await getSafePublicJWKS();
|
||||||
res.json(jwks);
|
|
||||||
|
// there's only one key in the store atm
|
||||||
|
// based on this setting all of the keys to have
|
||||||
|
// "use": "sig" property
|
||||||
|
const keys = jwks.keys
|
||||||
|
.map(key => ({
|
||||||
|
e: key.e,
|
||||||
|
kid: key.kid,
|
||||||
|
kty: key.kty,
|
||||||
|
n: key.n,
|
||||||
|
use: 'sig'
|
||||||
|
}));
|
||||||
|
|
||||||
|
res.json({keys});
|
||||||
});
|
});
|
||||||
|
|
||||||
return wellKnownApp;
|
return wellKnownApp;
|
||||||
|
|
|
@ -8,6 +8,7 @@ Object {
|
||||||
"kid": Any<String>,
|
"kid": Any<String>,
|
||||||
"kty": "RSA",
|
"kty": "RSA",
|
||||||
"n": Any<String>,
|
"n": Any<String>,
|
||||||
|
"use": "sig",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
@ -15,7 +16,7 @@ Object {
|
||||||
|
|
||||||
exports[`.well-known GET /jwks.json should return a JWKS 2: [headers] 1`] = `
|
exports[`.well-known GET /jwks.json should return a JWKS 2: [headers] 1`] = `
|
||||||
Object {
|
Object {
|
||||||
"content-length": "265",
|
"content-length": "277",
|
||||||
"content-type": "application/json; charset=utf-8",
|
"content-type": "application/json; charset=utf-8",
|
||||||
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
||||||
"vary": "Accept-Encoding",
|
"vary": "Accept-Encoding",
|
||||||
|
|
Loading…
Add table
Reference in a new issue