2018-10-05 01:50:45 +03:00
|
|
|
module.exports = {
|
|
|
|
get permissions() {
|
|
|
|
return require('./permissions');
|
|
|
|
},
|
|
|
|
|
|
|
|
get serializers() {
|
|
|
|
return require('./serializers');
|
|
|
|
},
|
|
|
|
|
|
|
|
get validators() {
|
|
|
|
return require('./validators');
|
2018-11-06 15:06:22 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* TODO: We need to check for public context as permission stage overrides
|
|
|
|
* the whole context object currently: https://github.com/TryGhost/Ghost/issues/10099
|
|
|
|
*/
|
|
|
|
isContentAPI: (frame) => {
|
2019-02-14 20:17:02 +03:00
|
|
|
const context = frame.options && frame.options.context || {};
|
|
|
|
// CASE: An empty context is considered public by the core/server/services/permissions/parse-context.js
|
|
|
|
// module, replicated here because the context is unparsed until after the permissions layer of the pipeline
|
|
|
|
const isPublic = context.public || Object.keys(context).length === 0;
|
|
|
|
|
|
|
|
// CASE: apiType = 'content' for HTTP Content API
|
|
|
|
return frame.apiType === 'content' || isPublic;
|
2019-01-31 17:35:22 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
isAdminAPIKey: (frame) => {
|
|
|
|
return frame.options.context && Object.keys(frame.options.context).length !== 0 && frame.options.context.api_key &&
|
|
|
|
frame.options.context.api_key.type === 'admin';
|
2018-10-05 01:50:45 +03:00
|
|
|
}
|
|
|
|
};
|