mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 18:31:57 +03:00
24 lines
650 B
JavaScript
24 lines
650 B
JavaScript
|
const express = require('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();
|
||
|
|
||
|
wellKnownApp.get('/jwks.json', async (req, res) => {
|
||
|
const jwks = await getSafePublicJWKS();
|
||
|
res.json(jwks);
|
||
|
});
|
||
|
|
||
|
return wellKnownApp;
|
||
|
};
|