mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-28 21:33:24 +03:00
104f84f252
As discussed with the product team we want to enforce kebab-case file names for all files, with the exception of files which export a single class, in which case they should be PascalCase and reflect the class which they export. This will help find classes faster, and should push better naming for them too. Some files and packages have been excluded from this linting, specifically when a library or framework depends on the naming of a file for the functionality e.g. Ember, knex-migrator, adapter-manager
47 lines
1.1 KiB
JavaScript
47 lines
1.1 KiB
JavaScript
const errors = require('@tryghost/errors');
|
|
const logging = require('@tryghost/logging');
|
|
const tpl = require('@tryghost/tpl');
|
|
|
|
const messages = {
|
|
keyStoreError: 'There was an error with the keystore. Please check the settings.'
|
|
};
|
|
|
|
/**
|
|
* @typedef {import('node-jose').JWK[]} JWKS
|
|
*/
|
|
|
|
/**
|
|
* @typedef {object} ITokenService
|
|
* @prop {() => Promise<JWKS>} getPublicKeys
|
|
*/
|
|
|
|
module.exports = class WellKnownController {
|
|
/**
|
|
*
|
|
* @param {object} deps
|
|
* @param {ITokenService} deps.tokenService
|
|
*/
|
|
constructor(deps) {
|
|
this._tokenService = deps.tokenService;
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param {import('express').Request} req
|
|
* @param {import('express').Response} res
|
|
*/
|
|
async getPublicKeys(req, res) {
|
|
try {
|
|
const jwks = await this._tokenService.getPublicKeys();
|
|
res.json(jwks);
|
|
} catch (err) {
|
|
const error = new errors.InternalServerError({
|
|
message: tpl(messages.keyStoreError),
|
|
err
|
|
});
|
|
logging.error(error);
|
|
throw error;
|
|
}
|
|
}
|
|
};
|