mirror of
https://github.com/strapi/strapi.git
synced 2025-08-31 04:03:50 +00:00
Merge branch 'v4/backend' into pluginAPI/loadPlugin
This commit is contained in:
commit
dd0c095f1e
@ -2,6 +2,7 @@ module.exports = ({ env }) => ({
|
||||
host: env('HOST', '0.0.0.0'),
|
||||
port: env.int('PORT', 1337),
|
||||
admin: {
|
||||
// autoOpen: true,
|
||||
auth: {
|
||||
secret: env('ADMIN_JWT_SECRET', 'example-token'),
|
||||
},
|
||||
|
@ -1,3 +1,3 @@
|
||||
module.exports = {
|
||||
jwtSecret: process.env.JWT_SECRET || 'f12c8d28-5d60-401e-b480-3af1cb42febc',
|
||||
jwtSecret: process.env.JWT_SECRET || '6dc1785c-5916-462f-a75e-7ae5fcb480ae',
|
||||
};
|
||||
|
@ -1,8 +1,9 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"rootDir": ".",
|
||||
"module": "commonjs",
|
||||
"target": "es6"
|
||||
},
|
||||
"include": ["packages/**/*"],
|
||||
"exclude": ["**/node_modules/*"]
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
@ -2,11 +2,12 @@
|
||||
|
||||
// eslint-disable-next-line node/no-extraneous-require
|
||||
const { features } = require('@strapi/strapi/lib/utils/ee');
|
||||
const executeCEBootstrap = require('../../../config/functions/bootstrap');
|
||||
const executeCEBootstrap = require('../../../../server/config/functions/bootstrap');
|
||||
const {
|
||||
features: { sso: ssoActions },
|
||||
} = require('../admin-actions');
|
||||
const { getService } = require('../../../utils');
|
||||
|
||||
const { getService } = require('../../../../server/utils');
|
||||
|
||||
module.exports = async () => {
|
||||
const { actionProvider } = getService('permission');
|
8
packages/core/admin/ee/server/config/index.js
Normal file
8
packages/core/admin/ee/server/config/index.js
Normal file
@ -0,0 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
functions: {
|
||||
bootstrap: require('./functions/bootstrap'),
|
||||
},
|
||||
routes: require('./routes').routes,
|
||||
};
|
@ -2,7 +2,7 @@
|
||||
|
||||
const passport = require('koa-passport');
|
||||
|
||||
const { getService } = require('../../../utils');
|
||||
const { getService } = require('../../../../server/utils');
|
||||
const utils = require('./utils');
|
||||
|
||||
const defaultConnectionError = () => new Error('Invalid connection payload');
|
8
packages/core/admin/ee/server/controllers/index.js
Normal file
8
packages/core/admin/ee/server/controllers/index.js
Normal file
@ -0,0 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
authentication: require('./authentication'),
|
||||
permission: require('./permission'),
|
||||
role: require('./role'),
|
||||
user: require('./user'),
|
||||
};
|
@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { getService } = require('../../utils');
|
||||
const { formatConditions } = require('../../controllers/formatters');
|
||||
const { getService } = require('../../../server/utils');
|
||||
const { formatConditions } = require('../../../server/controllers/formatters');
|
||||
|
||||
module.exports = {
|
||||
async getAll(ctx) {
|
@ -6,9 +6,9 @@ const {
|
||||
validateRoleDeleteInput,
|
||||
validateRolesDeleteInput,
|
||||
} = require('../validation/role');
|
||||
const { getService } = require('../../utils');
|
||||
const { getService } = require('../../../server//utils');
|
||||
const { validatedUpdatePermissionsInput } = require('../validation/permission');
|
||||
const { SUPER_ADMIN_CODE } = require('../../services/constants');
|
||||
const { SUPER_ADMIN_CODE } = require('../../../server/services/constants');
|
||||
|
||||
module.exports = {
|
||||
/**
|
@ -2,7 +2,7 @@
|
||||
|
||||
const { pick } = require('lodash/fp');
|
||||
const { validateUserCreationInput } = require('../validation/user');
|
||||
const { getService } = require('../../utils');
|
||||
const { getService } = require('../../../server/utils');
|
||||
|
||||
const pickUserCreationAttributes = pick(['firstname', 'lastname', 'email', 'roles']);
|
||||
|
8
packages/core/admin/ee/server/index.js
Normal file
8
packages/core/admin/ee/server/index.js
Normal file
@ -0,0 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
// TODO: update load middleware to not load the admin middleware from here
|
||||
config: require('./config'),
|
||||
services: require('./services'),
|
||||
controllers: require('./controllers'),
|
||||
};
|
@ -7,7 +7,7 @@ jest.mock('koa-passport', () => ({
|
||||
|
||||
const passport = require('koa-passport');
|
||||
|
||||
const { init } = require('../../../services/passport');
|
||||
const { init } = require('../../../../server/services/passport');
|
||||
|
||||
describe('Passport', () => {
|
||||
afterEach(() => {
|
6
packages/core/admin/ee/server/services/index.js
Normal file
6
packages/core/admin/ee/server/services/index.js
Normal file
@ -0,0 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
passport: require('./passport'),
|
||||
role: require('./role'),
|
||||
};
|
@ -3,7 +3,7 @@
|
||||
// eslint-disable-next-line node/no-extraneous-require
|
||||
const { features } = require('@strapi/strapi/lib/utils/ee');
|
||||
|
||||
const createLocalStrategy = require('../../services/passport/local-strategy');
|
||||
const createLocalStrategy = require('../../../server/services/passport/local-strategy');
|
||||
const sso = require('./passport/sso');
|
||||
|
||||
const getPassportStrategies = () => {
|
@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const { authEventsMapper } = require('../../../services/passport');
|
||||
const { authEventsMapper } = require('../../../../server/services/passport');
|
||||
const createProviderRegistry = require('./provider-registry');
|
||||
|
||||
const providerRegistry = createProviderRegistry();
|
@ -1,8 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
const { createStrapiInstance } = require('../../../../../test/helpers/strapi');
|
||||
const { createAuthRequest, createRequest } = require('../../../../../test/helpers/request');
|
||||
const { createUtils } = require('../../../../../test/helpers/utils');
|
||||
const { createStrapiInstance } = require('../../../../../../test/helpers/strapi');
|
||||
const { createAuthRequest, createRequest } = require('../../../../../../test/helpers/request');
|
||||
const { createUtils } = require('../../../../../../test/helpers/utils');
|
||||
|
||||
const edition = process.env.STRAPI_DISABLE_EE === 'true' ? 'CE' : 'EE';
|
||||
|
@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { formatYupErrors } = require('@strapi/utils');
|
||||
const validators = require('../../validation/common-validators');
|
||||
const validators = require('../../../server/validation/common-validators');
|
||||
|
||||
const handleReject = error => Promise.reject(formatYupErrors(error));
|
||||
|
@ -3,7 +3,7 @@
|
||||
const { yup, formatYupErrors } = require('@strapi/utils');
|
||||
// eslint-disable-next-line node/no-extraneous-require
|
||||
const { features } = require('@strapi/strapi/lib/utils/ee');
|
||||
const { schemas } = require('../../validation/user');
|
||||
const { schemas } = require('../../../server/validation/user');
|
||||
|
||||
const handleReject = error => Promise.reject(formatYupErrors(error));
|
||||
|
3
packages/core/admin/ee/strapi-server.js
Normal file
3
packages/core/admin/ee/strapi-server.js
Normal file
@ -0,0 +1,3 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = require('./server');
|
@ -150,7 +150,7 @@ async function copyAdmin(dest) {
|
||||
await fs.ensureDir(path.resolve(dest, 'config'));
|
||||
await fs.copy(path.resolve(adminPath, 'admin'), path.resolve(dest, 'admin'));
|
||||
await fs.copy(
|
||||
path.resolve(adminPath, 'config', 'layout.js'),
|
||||
path.resolve(adminPath, 'server', 'config', 'layout.js'),
|
||||
path.resolve(dest, 'config', 'layout.js')
|
||||
);
|
||||
|
||||
|
5
packages/core/admin/server/bootstrap.js
vendored
5
packages/core/admin/server/bootstrap.js
vendored
@ -1,5 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const bootstrap = require('../config/functions/bootstrap');
|
||||
|
||||
module.exports = bootstrap;
|
@ -1,10 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const settings = require('../config/settings');
|
||||
|
||||
module.exports = {
|
||||
default: {
|
||||
settings,
|
||||
},
|
||||
validator: () => {},
|
||||
};
|
@ -55,11 +55,4 @@ module.exports = async () => {
|
||||
await userService.displayWarningIfUsersDontHaveRole();
|
||||
|
||||
await syncAuthSettings();
|
||||
|
||||
strapi.admin.destroy = async () => {
|
||||
const { conditionProvider, actionProvider } = getService('permission');
|
||||
|
||||
await conditionProvider.clear();
|
||||
await actionProvider.clear();
|
||||
};
|
||||
};
|
15
packages/core/admin/server/config/index.js
Normal file
15
packages/core/admin/server/config/index.js
Normal file
@ -0,0 +1,15 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
functions: {
|
||||
bootstrap: require('./functions/bootstrap'),
|
||||
register: require('./functions/register'),
|
||||
},
|
||||
policies: {
|
||||
hasPermissions: require('./policies/hasPermissions'),
|
||||
isAuthenticatedAdmin: require('./policies/isAuthenticatedAdmin'),
|
||||
},
|
||||
routes: require('./routes').routes,
|
||||
layout: require('./layout'),
|
||||
...require('./settings'),
|
||||
};
|
@ -11,7 +11,7 @@ module.exports = {
|
||||
description: '',
|
||||
singularName: 'role',
|
||||
pluralName: 'roles',
|
||||
displayName: 'Role'
|
||||
displayName: 'Role',
|
||||
},
|
||||
options: {},
|
||||
pluginOptions: {
|
@ -11,7 +11,7 @@ module.exports = {
|
||||
description: '',
|
||||
singularName: 'user',
|
||||
pluralName: 'users',
|
||||
displayName: 'User'
|
||||
displayName: 'User',
|
||||
},
|
||||
pluginOptions: {
|
||||
'content-manager': {
|
@ -1,17 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const permission = require('../../models/Permission');
|
||||
const role = require('../../models/Role');
|
||||
const user = require('../../models/User');
|
||||
|
||||
module.exports = [
|
||||
{
|
||||
schema: permission,
|
||||
},
|
||||
{
|
||||
schema: role,
|
||||
},
|
||||
{
|
||||
schema: user,
|
||||
},
|
||||
];
|
||||
module.exports = {
|
||||
permission: require('./Permission'),
|
||||
user: require('./User'),
|
||||
role: require('./Role'),
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const createContext = require('../../../../../test/helpers/create-context');
|
||||
const createContext = require('../../../../../../test/helpers/create-context');
|
||||
const permissionController = require('../permission');
|
||||
|
||||
describe('Permission Controller', () => {
|
@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const createContext = require('../../../../../test/helpers/create-context');
|
||||
const createContext = require('../../../../../../test/helpers/create-context');
|
||||
const roleController = require('../role');
|
||||
|
||||
describe('Role controller', () => {
|
@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const createContext = require('../../../../../test/helpers/create-context');
|
||||
const createContext = require('../../../../../../test/helpers/create-context');
|
||||
const userController = require('../user');
|
||||
|
||||
describe('User Controller', () => {
|
@ -2,12 +2,12 @@
|
||||
|
||||
const execa = require('execa');
|
||||
const _ = require('lodash');
|
||||
const { getService } = require('../utils');
|
||||
|
||||
// FIXME
|
||||
// eslint-disable-next-line node/no-extraneous-require
|
||||
const ee = require('@strapi/strapi/lib/utils/ee');
|
||||
|
||||
const { getService } = require('../utils');
|
||||
|
||||
const PLUGIN_NAME_REGEX = /^[A-Za-z][A-Za-z0-9-_]+$/;
|
||||
|
||||
/**
|
@ -1,19 +1,11 @@
|
||||
'use strict';
|
||||
|
||||
const admin = require('../../controllers/admin');
|
||||
const authentication = require('../../controllers/authentication');
|
||||
const permission = require('../../controllers/permission');
|
||||
const role = require('../../controllers/role');
|
||||
const user = require('../../controllers/user');
|
||||
const webhooks = require('../../controllers/Webhooks');
|
||||
const authenticatedUser = require('../../controllers/authenticated-user');
|
||||
|
||||
module.exports = {
|
||||
admin,
|
||||
authentication,
|
||||
permission,
|
||||
role,
|
||||
user,
|
||||
webhooks,
|
||||
'authenticated-user': authenticatedUser,
|
||||
admin: require('./admin'),
|
||||
'authenticated-user': require('./authenticated-user'),
|
||||
authentication: require('./authentication'),
|
||||
permission: require('./permission'),
|
||||
role: require('./role'),
|
||||
user: require('./user'),
|
||||
webhooks: require('./Webhooks'),
|
||||
};
|
||||
|
18
packages/core/admin/server/index.js
Normal file
18
packages/core/admin/server/index.js
Normal file
@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
const { getService } = require('./utils');
|
||||
|
||||
module.exports = {
|
||||
// TODO: update load middleware to not load the admin middleware from here
|
||||
// TODO: load bootstrap / register independently
|
||||
async destroy() {
|
||||
const { conditionProvider, actionProvider } = getService('permission');
|
||||
|
||||
await conditionProvider.clear();
|
||||
await actionProvider.clear();
|
||||
},
|
||||
config: require('./config'),
|
||||
services: require('./services'),
|
||||
controllers: require('./controllers'),
|
||||
models: require('./content-types'),
|
||||
};
|
@ -1,9 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const hasPermissions = require('../../config/policies/hasPermissions');
|
||||
const isAuthenticatedAdmin = require('../../config/policies/isAuthenticatedAdmin');
|
||||
|
||||
module.exports = {
|
||||
hasPermissions,
|
||||
isAuthenticatedAdmin,
|
||||
};
|
@ -1,5 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const register = require('../config/functions/register');
|
||||
|
||||
module.exports = register;
|
@ -1,5 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const routes = require('../../config/routes');
|
||||
|
||||
module.exports = routes.routes;
|
@ -1,25 +1,15 @@
|
||||
'use strict';
|
||||
|
||||
const action = require('../../services/action');
|
||||
const auth = require('../../services/auth');
|
||||
const condition = require('../../services/condition');
|
||||
const contentType = require('../../services/content-type');
|
||||
const metrics = require('../../services/metrics');
|
||||
const passport = require('../../services/passport');
|
||||
const permission = require('../../services/permission');
|
||||
const role = require('../../services/role');
|
||||
const token = require('../../services/token');
|
||||
const user = require('../../services/user');
|
||||
|
||||
module.exports = {
|
||||
action,
|
||||
auth,
|
||||
condition,
|
||||
'content-type': contentType,
|
||||
metrics,
|
||||
passport,
|
||||
permission,
|
||||
role,
|
||||
token,
|
||||
user,
|
||||
user: require('./user'),
|
||||
token: require('./token'),
|
||||
role: require('./role'),
|
||||
permission: require('./permission'),
|
||||
passport: require('./passport'),
|
||||
metrics: require('./metrics'),
|
||||
'content-type': require('./content-type'),
|
||||
constants: require('./constants'),
|
||||
condition: require('./condition'),
|
||||
auth: require('./auth'),
|
||||
action: require('./action'),
|
||||
};
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user