mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 18:31:57 +03:00
53d14fd8e3
- Added a wrapper around express.Router to our shared/express util - Also export static and _express - Use this shared util everywhre, meaning express is only used directly in this one file - ATM this file is mostly an experiment / debug helper, it might be removed again later - The aim is to have a minimal framework wrapping express that allows us to: - reduce our usage of express() in favour of Router() - unify some of our duplicated logic - fix some structural issues e.g. Sentry - make it easier to understand the codebase
24 lines
675 B
JavaScript
24 lines
675 B
JavaScript
const express = require('../../shared/express');
|
|
const settings = require('../services/settings/cache');
|
|
const jose = require('node-jose');
|
|
|
|
const dangerousPrivateKey = settings.get('ghost_private_key');
|
|
const keyStore = jose.JWK.createKeyStore();
|
|
const keyStoreReady = keyStore.add(dangerousPrivateKey, 'pem');
|
|
|
|
const getSafePublicJWKS = async () => {
|
|
await keyStoreReady;
|
|
return keyStore.toJSON();
|
|
};
|
|
|
|
module.exports = function setupWellKnownApp() {
|
|
const wellKnownApp = express('well-known');
|
|
|
|
wellKnownApp.get('/jwks.json', async (req, res) => {
|
|
const jwks = await getSafePublicJWKS();
|
|
res.json(jwks);
|
|
});
|
|
|
|
return wellKnownApp;
|
|
};
|