diff --git a/packages/core/admin/ee/server/routes/audit-logs.js b/packages/core/admin/ee/server/routes/audit-logs.js new file mode 100644 index 0000000000..5f6a555fda --- /dev/null +++ b/packages/core/admin/ee/server/routes/audit-logs.js @@ -0,0 +1,43 @@ +'use strict'; + +const { enableFeatureMiddleware } = require('./utils'); + +module.exports = { + type: 'admin', + routes: [ + { + method: 'GET', + path: '/audit-logs', + handler: 'auditLogs.findMany', + config: { + middlewares: [enableFeatureMiddleware('audit-logs')], + policies: [ + 'admin::isAuthenticatedAdmin', + { + name: 'admin::hasPermissions', + config: { + actions: ['admin::audit-logs.read'], + }, + }, + ], + }, + }, + { + method: 'GET', + path: '/audit-logs/:id', + handler: 'auditLogs.findOne', + config: { + middlewares: [enableFeatureMiddleware('audit-logs')], + policies: [ + 'admin::isAuthenticatedAdmin', + { + name: 'admin::hasPermissions', + config: { + actions: ['admin::audit-logs.read'], + }, + }, + ], + }, + }, + ], +}; diff --git a/packages/core/admin/ee/server/routes/index.js b/packages/core/admin/ee/server/routes/index.js index e789639768..4bffca4fd3 100644 --- a/packages/core/admin/ee/server/routes/index.js +++ b/packages/core/admin/ee/server/routes/index.js @@ -1,229 +1,8 @@ 'use strict'; -const { features } = require('@strapi/strapi/lib/utils/ee'); - -const enableFeatureMiddleware = (featureName) => (ctx, next) => { - if (features.isEnabled(featureName)) { - return next(); - } - - ctx.status = 404; +module.exports = { + sso: require('./sso'), + 'license-limit': require('./license-limit'), + 'audit-logs': require('./audit-logs'), + 'review-workflows': require('./review-workflows'), }; - -module.exports = [ - // SSO - { - method: 'GET', - path: '/providers', - handler: 'authentication.getProviders', - config: { - middlewares: [enableFeatureMiddleware('sso')], - auth: false, - }, - }, - { - method: 'GET', - path: '/connect/:provider', - handler: 'authentication.providerLogin', - config: { - middlewares: [enableFeatureMiddleware('sso')], - auth: false, - }, - }, - { - method: 'POST', - path: '/connect/:provider', - handler: 'authentication.providerLogin', - config: { - middlewares: [enableFeatureMiddleware('sso')], - auth: false, - }, - }, - { - method: 'GET', - path: '/providers/options', - handler: 'authentication.getProviderLoginOptions', - config: { - middlewares: [enableFeatureMiddleware('sso')], - policies: [ - 'admin::isAuthenticatedAdmin', - { name: 'admin::hasPermissions', config: { actions: ['admin::provider-login.read'] } }, - ], - }, - }, - { - method: 'PUT', - path: '/providers/options', - handler: 'authentication.updateProviderLoginOptions', - config: { - middlewares: [enableFeatureMiddleware('sso')], - policies: [ - 'admin::isAuthenticatedAdmin', - { name: 'admin::hasPermissions', config: { actions: ['admin::provider-login.update'] } }, - ], - }, - }, - - // Audit logs - { - method: 'GET', - path: '/audit-logs', - handler: 'auditLogs.findMany', - config: { - middlewares: [enableFeatureMiddleware('audit-logs')], - policies: [ - 'admin::isAuthenticatedAdmin', - { - name: 'admin::hasPermissions', - config: { - actions: ['admin::audit-logs.read'], - }, - }, - ], - }, - }, - { - method: 'GET', - path: '/audit-logs/:id', - handler: 'auditLogs.findOne', - config: { - middlewares: [enableFeatureMiddleware('audit-logs')], - policies: [ - 'admin::isAuthenticatedAdmin', - { - name: 'admin::hasPermissions', - config: { - actions: ['admin::audit-logs.read'], - }, - }, - ], - }, - }, - - // License limit infos - { - method: 'GET', - path: '/license-limit-information', - handler: 'admin.licenseLimitInformation', - config: { - policies: [ - 'admin::isAuthenticatedAdmin', - { - name: 'admin::hasPermissions', - config: { - actions: [ - 'admin::users.create', - 'admin::users.read', - 'admin::users.update', - 'admin::users.delete', - ], - }, - }, - ], - }, - }, - - // Review workflow - { - method: 'GET', - path: '/review-workflows/workflows', - handler: 'workflows.find', - config: { - middlewares: [enableFeatureMiddleware('review-workflows')], - policies: [ - 'admin::isAuthenticatedAdmin', - { - name: 'admin::hasPermissions', - config: { - actions: ['admin::review-workflows.read'], - }, - }, - ], - }, - }, - { - method: 'GET', - path: '/review-workflows/workflows/:id', - handler: 'workflows.findById', - config: { - middlewares: [enableFeatureMiddleware('review-workflows')], - policies: [ - 'admin::isAuthenticatedAdmin', - { - name: 'admin::hasPermissions', - config: { - actions: ['admin::review-workflows.read'], - }, - }, - ], - }, - }, - { - method: 'GET', - path: '/review-workflows/workflows/:workflow_id/stages', - handler: 'stages.find', - config: { - middlewares: [enableFeatureMiddleware('review-workflows')], - policies: [ - 'admin::isAuthenticatedAdmin', - { - name: 'admin::hasPermissions', - config: { - actions: ['admin::review-workflows.read'], - }, - }, - ], - }, - }, - { - method: 'PUT', - path: '/review-workflows/workflows/:workflow_id/stages', - handler: 'stages.replace', - config: { - middlewares: [enableFeatureMiddleware('review-workflows')], - policies: [ - 'admin::isAuthenticatedAdmin', - { - name: 'admin::hasPermissions', - config: { - actions: ['admin::review-workflows.read'], - }, - }, - ], - }, - }, - { - method: 'GET', - path: '/review-workflows/workflows/:workflow_id/stages/:id', - handler: 'stages.findById', - config: { - middlewares: [enableFeatureMiddleware('review-workflows')], - policies: [ - 'admin::isAuthenticatedAdmin', - { - name: 'admin::hasPermissions', - config: { - actions: ['admin::review-workflows.read'], - }, - }, - ], - }, - }, - { - method: 'PUT', - path: '/content-manager/(collection|single)-types/:model_uid/:id/stage', - handler: 'stages.updateEntity', - config: { - middlewares: [enableFeatureMiddleware('review-workflows')], - policies: [ - 'admin::isAuthenticatedAdmin', - { - name: 'admin::hasPermissions', - config: { - actions: ['admin::review-workflows.read'], - }, - }, - ], - }, - }, -]; diff --git a/packages/core/admin/ee/server/routes/license-limit.js b/packages/core/admin/ee/server/routes/license-limit.js new file mode 100644 index 0000000000..710458eb3c --- /dev/null +++ b/packages/core/admin/ee/server/routes/license-limit.js @@ -0,0 +1,29 @@ +'use strict'; + +module.exports = { + type: 'admin', + routes: [ + // License limit infos + { + method: 'GET', + path: '/license-limit-information', + handler: 'admin.licenseLimitInformation', + config: { + policies: [ + 'admin::isAuthenticatedAdmin', + { + name: 'admin::hasPermissions', + config: { + actions: [ + 'admin::users.create', + 'admin::users.read', + 'admin::users.update', + 'admin::users.delete', + ], + }, + }, + ], + }, + }, + ], +}; diff --git a/packages/core/admin/ee/server/routes/review-workflows.js b/packages/core/admin/ee/server/routes/review-workflows.js new file mode 100644 index 0000000000..1bcd412fd5 --- /dev/null +++ b/packages/core/admin/ee/server/routes/review-workflows.js @@ -0,0 +1,112 @@ +'use strict'; + +const { enableFeatureMiddleware } = require('./utils'); + +module.exports = { + type: 'admin', + routes: [ + // Review workflow + { + method: 'GET', + path: '/review-workflows/workflows', + handler: 'workflows.find', + config: { + middlewares: [enableFeatureMiddleware('review-workflows')], + policies: [ + 'admin::isAuthenticatedAdmin', + { + name: 'admin::hasPermissions', + config: { + actions: ['admin::review-workflows.read'], + }, + }, + ], + }, + }, + { + method: 'GET', + path: '/review-workflows/workflows/:id', + handler: 'workflows.findById', + config: { + middlewares: [enableFeatureMiddleware('review-workflows')], + policies: [ + 'admin::isAuthenticatedAdmin', + { + name: 'admin::hasPermissions', + config: { + actions: ['admin::review-workflows.read'], + }, + }, + ], + }, + }, + { + method: 'GET', + path: '/review-workflows/workflows/:workflow_id/stages', + handler: 'stages.find', + config: { + middlewares: [enableFeatureMiddleware('review-workflows')], + policies: [ + 'admin::isAuthenticatedAdmin', + { + name: 'admin::hasPermissions', + config: { + actions: ['admin::review-workflows.read'], + }, + }, + ], + }, + }, + { + method: 'PUT', + path: '/review-workflows/workflows/:workflow_id/stages', + handler: 'stages.replace', + config: { + middlewares: [enableFeatureMiddleware('review-workflows')], + policies: [ + 'admin::isAuthenticatedAdmin', + { + name: 'admin::hasPermissions', + config: { + actions: ['admin::review-workflows.read'], + }, + }, + ], + }, + }, + { + method: 'GET', + path: '/review-workflows/workflows/:workflow_id/stages/:id', + handler: 'stages.findById', + config: { + middlewares: [enableFeatureMiddleware('review-workflows')], + policies: [ + 'admin::isAuthenticatedAdmin', + { + name: 'admin::hasPermissions', + config: { + actions: ['admin::review-workflows.read'], + }, + }, + ], + }, + }, + { + method: 'PUT', + path: '/content-manager/(collection|single)-types/:model_uid/:id/stage', + handler: 'stages.updateEntity', + config: { + middlewares: [enableFeatureMiddleware('review-workflows')], + policies: [ + 'admin::isAuthenticatedAdmin', + { + name: 'admin::hasPermissions', + config: { + actions: ['admin::review-workflows.read'], + }, + }, + ], + }, + }, + ], +}; diff --git a/packages/core/admin/ee/server/routes/sso.js b/packages/core/admin/ee/server/routes/sso.js new file mode 100644 index 0000000000..88c0f785d9 --- /dev/null +++ b/packages/core/admin/ee/server/routes/sso.js @@ -0,0 +1,60 @@ +'use strict'; + +const { enableFeatureMiddleware } = require('./utils'); + +module.exports = { + type: 'admin', + routes: [ + { + method: 'GET', + path: '/providers', + handler: 'authentication.getProviders', + config: { + middlewares: [enableFeatureMiddleware('sso')], + auth: false, + }, + }, + { + method: 'GET', + path: '/connect/:provider', + handler: 'authentication.providerLogin', + config: { + middlewares: [enableFeatureMiddleware('sso')], + auth: false, + }, + }, + { + method: 'POST', + path: '/connect/:provider', + handler: 'authentication.providerLogin', + config: { + middlewares: [enableFeatureMiddleware('sso')], + auth: false, + }, + }, + { + method: 'GET', + path: '/providers/options', + handler: 'authentication.getProviderLoginOptions', + config: { + middlewares: [enableFeatureMiddleware('sso')], + policies: [ + 'admin::isAuthenticatedAdmin', + { name: 'admin::hasPermissions', config: { actions: ['admin::provider-login.read'] } }, + ], + }, + }, + { + method: 'PUT', + path: '/providers/options', + handler: 'authentication.updateProviderLoginOptions', + config: { + middlewares: [enableFeatureMiddleware('sso')], + policies: [ + 'admin::isAuthenticatedAdmin', + { name: 'admin::hasPermissions', config: { actions: ['admin::provider-login.update'] } }, + ], + }, + }, + ], +};