0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Removed support for external apps from Proxy

no-issue

This also removes the need for permissions, as internal apps have all permissions
This commit is contained in:
Fabien O'Carroll 2019-04-15 12:25:05 +02:00
parent 4b74c11abb
commit e4db1eed81
2 changed files with 13 additions and 41 deletions

View file

@ -1,7 +1,7 @@
var fs = require('fs-extra'),
Promise = require('bluebird'),
path = require('path'),
packageJSON = require('../../lib/fs/package-json');
const fs = require('fs-extra');
const Promise = require('bluebird');
const path = require('path');
const packageJSON = require('../../lib/fs/package-json');
function AppPermissions(appPath) {
this.appPath = appPath;

View file

@ -1,45 +1,17 @@
const _ = require('lodash'),
api = require('../../api/v0.1'),
helpers = require('../../helpers/register'),
filters = require('../../filters'),
common = require('../../lib/common'),
routingService = require('../routing');
const _ = require('lodash');
const api = require('../../api/v0.1');
const helpers = require('../../helpers/register');
const filters = require('../../filters');
const common = require('../../lib/common');
const routingService = require('../routing');
let generateProxyFunctions;
generateProxyFunctions = function (name, permissions, isInternal) {
generateProxyFunctions = function (name) {
const appRouter = routingService.registry.getRouter('appRouter');
var getPermission = function (perm) {
return permissions[perm];
},
getPermissionToMethod = function (perm, method) {
var perms = getPermission(perm);
if (!perms) {
return false;
}
return _.find(perms, function (name) {
return name === method;
});
},
runIfPermissionToMethod = function (perm, method, wrappedFunc, context, args) {
var runIfPermissionToMethod = function (perm, method, wrappedFunc, context, args) {
// internal apps get all permissions
if (isInternal) {
return wrappedFunc.apply(context, args);
}
var permValue = getPermissionToMethod(perm, method);
if (!permValue) {
throw new Error(common.i18n.t('errors.apps.accessResourceWithoutPermission.error', {
name: name,
perm: perm,
method: method
}));
}
return wrappedFunc.apply(context, args);
},
checkRegisterPermissions = function (perm, registerMethod) {
@ -111,7 +83,7 @@ function AppProxy(options) {
throw new Error(common.i18n.t('errors.apps.mustProvideAppPermissions.error'));
}
_.extend(this, generateProxyFunctions(options.name, options.permissions, options.internal));
_.extend(this, generateProxyFunctions(options.name));
}
module.exports = AppProxy;