mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 22:02:11 +03:00
bd597db829
- This is part of the quest to separate the frontend and server & get rid of all the places where there are cross-requires - At the moment the settings cache is one big shared cache used by the frontend and server liberally - This change doesn't really solve the fundamental problems, as we still depend on events, and requires from inside frontend - However it allows us to control the misuse slightly better by getting rid of restricted requires and turning on that eslint ruleset
24 lines
676 B
JavaScript
24 lines
676 B
JavaScript
const express = require('../../shared/express');
|
|
const settings = require('../../shared/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;
|
|
};
|