mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 06:34:05 -08:00
refactor(core): Rename RequireGlobalScope to GlobalScope (no-changelog) (#8760)
This commit is contained in:
parent
246bfb9ad4
commit
2811f77798
|
@ -1,4 +1,4 @@
|
|||
import { Authorized, Get, Post, RestController, RequireGlobalScope } from '@/decorators';
|
||||
import { Authorized, Get, Post, RestController, GlobalScope } from '@/decorators';
|
||||
import { ExternalSecretsRequest } from '@/requests';
|
||||
import { Response } from 'express';
|
||||
import { ExternalSecretsService } from './ExternalSecrets.service.ee';
|
||||
|
@ -11,13 +11,13 @@ export class ExternalSecretsController {
|
|||
constructor(private readonly secretsService: ExternalSecretsService) {}
|
||||
|
||||
@Get('/providers')
|
||||
@RequireGlobalScope('externalSecretsProvider:list')
|
||||
@GlobalScope('externalSecretsProvider:list')
|
||||
async getProviders() {
|
||||
return await this.secretsService.getProviders();
|
||||
}
|
||||
|
||||
@Get('/providers/:provider')
|
||||
@RequireGlobalScope('externalSecretsProvider:read')
|
||||
@GlobalScope('externalSecretsProvider:read')
|
||||
async getProvider(req: ExternalSecretsRequest.GetProvider) {
|
||||
const providerName = req.params.provider;
|
||||
try {
|
||||
|
@ -31,7 +31,7 @@ export class ExternalSecretsController {
|
|||
}
|
||||
|
||||
@Post('/providers/:provider/test')
|
||||
@RequireGlobalScope('externalSecretsProvider:read')
|
||||
@GlobalScope('externalSecretsProvider:read')
|
||||
async testProviderSettings(req: ExternalSecretsRequest.TestProviderSettings, res: Response) {
|
||||
const providerName = req.params.provider;
|
||||
try {
|
||||
|
@ -51,7 +51,7 @@ export class ExternalSecretsController {
|
|||
}
|
||||
|
||||
@Post('/providers/:provider')
|
||||
@RequireGlobalScope('externalSecretsProvider:create')
|
||||
@GlobalScope('externalSecretsProvider:create')
|
||||
async setProviderSettings(req: ExternalSecretsRequest.SetProviderSettings) {
|
||||
const providerName = req.params.provider;
|
||||
try {
|
||||
|
@ -66,7 +66,7 @@ export class ExternalSecretsController {
|
|||
}
|
||||
|
||||
@Post('/providers/:provider/connect')
|
||||
@RequireGlobalScope('externalSecretsProvider:update')
|
||||
@GlobalScope('externalSecretsProvider:update')
|
||||
async setProviderConnected(req: ExternalSecretsRequest.SetProviderConnected) {
|
||||
const providerName = req.params.provider;
|
||||
try {
|
||||
|
@ -81,7 +81,7 @@ export class ExternalSecretsController {
|
|||
}
|
||||
|
||||
@Post('/providers/:provider/update')
|
||||
@RequireGlobalScope('externalSecretsProvider:sync')
|
||||
@GlobalScope('externalSecretsProvider:sync')
|
||||
async updateProvider(req: ExternalSecretsRequest.UpdateProvider, res: Response) {
|
||||
const providerName = req.params.provider;
|
||||
try {
|
||||
|
@ -101,7 +101,7 @@ export class ExternalSecretsController {
|
|||
}
|
||||
|
||||
@Get('/secrets')
|
||||
@RequireGlobalScope('externalSecret:list')
|
||||
@GlobalScope('externalSecret:list')
|
||||
getSecretNames() {
|
||||
return this.secretsService.getAllSecrets();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import pick from 'lodash/pick';
|
||||
import { Authorized, Get, Post, Put, RestController, RequireGlobalScope } from '@/decorators';
|
||||
import { Authorized, Get, Post, Put, RestController, GlobalScope } from '@/decorators';
|
||||
import { InternalHooks } from '@/InternalHooks';
|
||||
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
||||
|
||||
|
@ -17,13 +17,13 @@ export class LdapController {
|
|||
) {}
|
||||
|
||||
@Get('/config')
|
||||
@RequireGlobalScope('ldap:manage')
|
||||
@GlobalScope('ldap:manage')
|
||||
async getConfig() {
|
||||
return await this.ldapService.loadConfig();
|
||||
}
|
||||
|
||||
@Post('/test-connection')
|
||||
@RequireGlobalScope('ldap:manage')
|
||||
@GlobalScope('ldap:manage')
|
||||
async testConnection() {
|
||||
try {
|
||||
await this.ldapService.testConnection();
|
||||
|
@ -33,7 +33,7 @@ export class LdapController {
|
|||
}
|
||||
|
||||
@Put('/config')
|
||||
@RequireGlobalScope('ldap:manage')
|
||||
@GlobalScope('ldap:manage')
|
||||
async updateConfig(req: LdapConfiguration.Update) {
|
||||
try {
|
||||
await this.ldapService.updateConfig(req.body);
|
||||
|
@ -52,14 +52,14 @@ export class LdapController {
|
|||
}
|
||||
|
||||
@Get('/sync')
|
||||
@RequireGlobalScope('ldap:sync')
|
||||
@GlobalScope('ldap:sync')
|
||||
async getLdapSync(req: LdapConfiguration.GetSync) {
|
||||
const { page = '0', perPage = '20' } = req.query;
|
||||
return await getLdapSynchronizations(parseInt(page, 10), parseInt(perPage, 10));
|
||||
}
|
||||
|
||||
@Post('/sync')
|
||||
@RequireGlobalScope('ldap:sync')
|
||||
@GlobalScope('ldap:sync')
|
||||
async syncLdap(req: LdapConfiguration.Sync) {
|
||||
try {
|
||||
await this.ldapService.runSync(req.body.type);
|
||||
|
|
|
@ -13,7 +13,7 @@ import {
|
|||
Patch,
|
||||
Post,
|
||||
RestController,
|
||||
RequireGlobalScope,
|
||||
GlobalScope,
|
||||
} from '@/decorators';
|
||||
import { NodeRequest } from '@/requests';
|
||||
import type { InstalledPackages } from '@db/entities/InstalledPackages';
|
||||
|
@ -62,7 +62,7 @@ export class CommunityPackagesController {
|
|||
}
|
||||
|
||||
@Post('/')
|
||||
@RequireGlobalScope('communityPackage:install')
|
||||
@GlobalScope('communityPackage:install')
|
||||
async installPackage(req: NodeRequest.Post) {
|
||||
const { name } = req.body;
|
||||
|
||||
|
@ -159,7 +159,7 @@ export class CommunityPackagesController {
|
|||
}
|
||||
|
||||
@Get('/')
|
||||
@RequireGlobalScope('communityPackage:list')
|
||||
@GlobalScope('communityPackage:list')
|
||||
async getInstalledPackages() {
|
||||
const installedPackages = await this.communityPackagesService.getAllInstalledPackages();
|
||||
|
||||
|
@ -194,7 +194,7 @@ export class CommunityPackagesController {
|
|||
}
|
||||
|
||||
@Delete('/')
|
||||
@RequireGlobalScope('communityPackage:uninstall')
|
||||
@GlobalScope('communityPackage:uninstall')
|
||||
async uninstallPackage(req: NodeRequest.Delete) {
|
||||
const { name } = req.query;
|
||||
|
||||
|
@ -246,7 +246,7 @@ export class CommunityPackagesController {
|
|||
}
|
||||
|
||||
@Patch('/')
|
||||
@RequireGlobalScope('communityPackage:update')
|
||||
@GlobalScope('communityPackage:update')
|
||||
async updatePackage(req: NodeRequest.Update) {
|
||||
const { name } = req.body;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import validator from 'validator';
|
|||
|
||||
import { AuthService } from '@/auth/auth.service';
|
||||
import config from '@/config';
|
||||
import { Authorized, NoAuthRequired, Post, RequireGlobalScope, RestController } from '@/decorators';
|
||||
import { Authorized, NoAuthRequired, Post, GlobalScope, RestController } from '@/decorators';
|
||||
import { RESPONSE_ERROR_MESSAGES } from '@/constants';
|
||||
import { UserRequest } from '@/requests';
|
||||
import { License } from '@/License';
|
||||
|
@ -39,7 +39,7 @@ export class InvitationController {
|
|||
*/
|
||||
|
||||
@Post('/')
|
||||
@RequireGlobalScope('user:create')
|
||||
@GlobalScope('user:create')
|
||||
async inviteUser(req: UserRequest.Invite) {
|
||||
const isWithinUsersLimit = this.license.isWithinUsersLimit();
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Authorized, Post, RestController, RequireGlobalScope } from '@/decorators';
|
||||
import { Authorized, Post, RestController, GlobalScope } from '@/decorators';
|
||||
import { OrchestrationRequest } from '@/requests';
|
||||
import { OrchestrationService } from '@/services/orchestration.service';
|
||||
import { License } from '@/License';
|
||||
|
@ -15,7 +15,7 @@ export class OrchestrationController {
|
|||
* These endpoints do not return anything, they just trigger the messsage to
|
||||
* the workers to respond on Redis with their status.
|
||||
*/
|
||||
@RequireGlobalScope('orchestration:read')
|
||||
@GlobalScope('orchestration:read')
|
||||
@Post('/worker/status/:id')
|
||||
async getWorkersStatus(req: OrchestrationRequest.Get) {
|
||||
if (!this.licenseService.isWorkerViewLicensed()) return;
|
||||
|
@ -23,14 +23,14 @@ export class OrchestrationController {
|
|||
return await this.orchestrationService.getWorkerStatus(id);
|
||||
}
|
||||
|
||||
@RequireGlobalScope('orchestration:read')
|
||||
@GlobalScope('orchestration:read')
|
||||
@Post('/worker/status')
|
||||
async getWorkersStatusAll() {
|
||||
if (!this.licenseService.isWorkerViewLicensed()) return;
|
||||
return await this.orchestrationService.getWorkerStatus();
|
||||
}
|
||||
|
||||
@RequireGlobalScope('orchestration:list')
|
||||
@GlobalScope('orchestration:list')
|
||||
@Post('/worker/ids')
|
||||
async getWorkerIdsAll() {
|
||||
if (!this.licenseService.isWorkerViewLicensed()) return;
|
||||
|
|
|
@ -8,7 +8,7 @@ import {
|
|||
Patch,
|
||||
Post,
|
||||
RestController,
|
||||
RequireGlobalScope,
|
||||
GlobalScope,
|
||||
} from '@/decorators';
|
||||
import { TagService } from '@/services/tag.service';
|
||||
import { TagsRequest } from '@/requests';
|
||||
|
@ -30,13 +30,13 @@ export class TagsController {
|
|||
}
|
||||
|
||||
@Get('/')
|
||||
@RequireGlobalScope('tag:list')
|
||||
@GlobalScope('tag:list')
|
||||
async getAll(req: TagsRequest.GetAll) {
|
||||
return await this.tagService.getAll({ withUsageCount: req.query.withUsageCount === 'true' });
|
||||
}
|
||||
|
||||
@Post('/')
|
||||
@RequireGlobalScope('tag:create')
|
||||
@GlobalScope('tag:create')
|
||||
async createTag(req: TagsRequest.Create) {
|
||||
const tag = this.tagService.toEntity({ name: req.body.name });
|
||||
|
||||
|
@ -44,7 +44,7 @@ export class TagsController {
|
|||
}
|
||||
|
||||
@Patch('/:id(\\w+)')
|
||||
@RequireGlobalScope('tag:update')
|
||||
@GlobalScope('tag:update')
|
||||
async updateTag(req: TagsRequest.Update) {
|
||||
const newTag = this.tagService.toEntity({ id: req.params.id, name: req.body.name.trim() });
|
||||
|
||||
|
@ -52,7 +52,7 @@ export class TagsController {
|
|||
}
|
||||
|
||||
@Delete('/:id(\\w+)')
|
||||
@RequireGlobalScope('tag:delete')
|
||||
@GlobalScope('tag:delete')
|
||||
async deleteTag(req: TagsRequest.Delete) {
|
||||
const { id } = req.params;
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import { User } from '@db/entities/User';
|
|||
import { SharedCredentials } from '@db/entities/SharedCredentials';
|
||||
import { SharedWorkflow } from '@db/entities/SharedWorkflow';
|
||||
import {
|
||||
RequireGlobalScope,
|
||||
GlobalScope,
|
||||
Authorized,
|
||||
Delete,
|
||||
Get,
|
||||
|
@ -89,7 +89,7 @@ export class UsersController {
|
|||
}
|
||||
|
||||
@Get('/', { middlewares: listQueryMiddleware })
|
||||
@RequireGlobalScope('user:list')
|
||||
@GlobalScope('user:list')
|
||||
async listUsers(req: ListQuery.Request) {
|
||||
const { listQueryOptions } = req;
|
||||
|
||||
|
@ -110,7 +110,7 @@ export class UsersController {
|
|||
}
|
||||
|
||||
@Get('/:id/password-reset-link')
|
||||
@RequireGlobalScope('user:resetPassword')
|
||||
@GlobalScope('user:resetPassword')
|
||||
async getUserPasswordResetLink(req: UserRequest.PasswordResetLink) {
|
||||
const user = await this.userRepository.findOneOrFail({
|
||||
where: { id: req.params.id },
|
||||
|
@ -124,7 +124,7 @@ export class UsersController {
|
|||
}
|
||||
|
||||
@Patch('/:id/settings')
|
||||
@RequireGlobalScope('user:update')
|
||||
@GlobalScope('user:update')
|
||||
async updateUserSettings(req: UserRequest.UserSettingsUpdate) {
|
||||
const payload = plainToInstance(UserSettingsUpdatePayload, req.body);
|
||||
|
||||
|
@ -144,7 +144,7 @@ export class UsersController {
|
|||
* Delete a user. Optionally, designate a transferee for their workflows and credentials.
|
||||
*/
|
||||
@Delete('/:id')
|
||||
@RequireGlobalScope('user:delete')
|
||||
@GlobalScope('user:delete')
|
||||
async deleteUser(req: UserRequest.Delete) {
|
||||
const { id: idToDelete } = req.params;
|
||||
|
||||
|
@ -296,7 +296,7 @@ export class UsersController {
|
|||
}
|
||||
|
||||
@Patch('/:id/role')
|
||||
@RequireGlobalScope('user:changeRole')
|
||||
@GlobalScope('user:changeRole')
|
||||
@Licensed('feat:advancedPermissions')
|
||||
async changeGlobalRole(req: UserRequest.ChangeRole) {
|
||||
const { NO_ADMIN_ON_OWNER, NO_USER, NO_OWNER_ON_OWNER } =
|
||||
|
|
|
@ -2,7 +2,7 @@ import type { Scope } from '@n8n/permissions';
|
|||
import type { ScopeMetadata } from './types';
|
||||
import { CONTROLLER_REQUIRED_SCOPES } from './constants';
|
||||
|
||||
export const RequireGlobalScope = (scope: Scope | Scope[]) => {
|
||||
export const GlobalScope = (scope: Scope | Scope[]) => {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
return (target: Function | object, handlerName?: string) => {
|
||||
const controllerClass = handlerName ? target.constructor : target;
|
||||
|
|
|
@ -4,4 +4,4 @@ export { Get, Post, Put, Patch, Delete } from './Route';
|
|||
export { Middleware } from './Middleware';
|
||||
export { registerController } from './registerController';
|
||||
export { Licensed } from './Licensed';
|
||||
export { RequireGlobalScope } from './Scopes';
|
||||
export { GlobalScope } from './Scopes';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import type { PullResult } from 'simple-git';
|
||||
import express from 'express';
|
||||
import { Authorized, Get, Post, Patch, RestController, RequireGlobalScope } from '@/decorators';
|
||||
import { Authorized, Get, Post, Patch, RestController, GlobalScope } from '@/decorators';
|
||||
import {
|
||||
sourceControlLicensedMiddleware,
|
||||
sourceControlLicensedAndEnabledMiddleware,
|
||||
|
@ -34,7 +34,7 @@ export class SourceControlController {
|
|||
}
|
||||
|
||||
@Post('/preferences', { middlewares: [sourceControlLicensedMiddleware] })
|
||||
@RequireGlobalScope('sourceControl:manage')
|
||||
@GlobalScope('sourceControl:manage')
|
||||
async setPreferences(req: SourceControlRequest.UpdatePreferences) {
|
||||
if (
|
||||
req.body.branchReadOnly === undefined &&
|
||||
|
@ -98,7 +98,7 @@ export class SourceControlController {
|
|||
}
|
||||
|
||||
@Patch('/preferences', { middlewares: [sourceControlLicensedMiddleware] })
|
||||
@RequireGlobalScope('sourceControl:manage')
|
||||
@GlobalScope('sourceControl:manage')
|
||||
async updatePreferences(req: SourceControlRequest.UpdatePreferences) {
|
||||
try {
|
||||
const sanitizedPreferences: Partial<SourceControlPreferences> = {
|
||||
|
@ -142,7 +142,7 @@ export class SourceControlController {
|
|||
}
|
||||
|
||||
@Post('/disconnect', { middlewares: [sourceControlLicensedMiddleware] })
|
||||
@RequireGlobalScope('sourceControl:manage')
|
||||
@GlobalScope('sourceControl:manage')
|
||||
async disconnect(req: SourceControlRequest.Disconnect) {
|
||||
try {
|
||||
return await this.sourceControlService.disconnect(req.body);
|
||||
|
@ -162,7 +162,7 @@ export class SourceControlController {
|
|||
}
|
||||
|
||||
@Post('/push-workfolder', { middlewares: [sourceControlLicensedAndEnabledMiddleware] })
|
||||
@RequireGlobalScope('sourceControl:push')
|
||||
@GlobalScope('sourceControl:push')
|
||||
async pushWorkfolder(
|
||||
req: SourceControlRequest.PushWorkFolder,
|
||||
res: express.Response,
|
||||
|
@ -184,7 +184,7 @@ export class SourceControlController {
|
|||
}
|
||||
|
||||
@Post('/pull-workfolder', { middlewares: [sourceControlLicensedAndEnabledMiddleware] })
|
||||
@RequireGlobalScope('sourceControl:pull')
|
||||
@GlobalScope('sourceControl:pull')
|
||||
async pullWorkfolder(
|
||||
req: SourceControlRequest.PullWorkFolder,
|
||||
res: express.Response,
|
||||
|
@ -203,7 +203,7 @@ export class SourceControlController {
|
|||
}
|
||||
|
||||
@Get('/reset-workfolder', { middlewares: [sourceControlLicensedAndEnabledMiddleware] })
|
||||
@RequireGlobalScope('sourceControl:manage')
|
||||
@GlobalScope('sourceControl:manage')
|
||||
async resetWorkfolder(): Promise<ImportResult | undefined> {
|
||||
try {
|
||||
return await this.sourceControlService.resetWorkfolder();
|
||||
|
@ -236,7 +236,7 @@ export class SourceControlController {
|
|||
}
|
||||
|
||||
@Post('/generate-key-pair', { middlewares: [sourceControlLicensedMiddleware] })
|
||||
@RequireGlobalScope('sourceControl:manage')
|
||||
@GlobalScope('sourceControl:manage')
|
||||
async generateKeyPair(
|
||||
req: SourceControlRequest.GenerateKeyPair,
|
||||
): Promise<SourceControlPreferences> {
|
||||
|
|
|
@ -6,7 +6,7 @@ import {
|
|||
Licensed,
|
||||
Patch,
|
||||
Post,
|
||||
RequireGlobalScope,
|
||||
GlobalScope,
|
||||
RestController,
|
||||
} from '@/decorators';
|
||||
import { VariablesService } from './variables.service.ee';
|
||||
|
@ -21,14 +21,14 @@ export class VariablesController {
|
|||
constructor(private readonly variablesService: VariablesService) {}
|
||||
|
||||
@Get('/')
|
||||
@RequireGlobalScope('variable:list')
|
||||
@GlobalScope('variable:list')
|
||||
async getVariables() {
|
||||
return await this.variablesService.getAllCached();
|
||||
}
|
||||
|
||||
@Post('/')
|
||||
@Licensed('feat:variables')
|
||||
@RequireGlobalScope('variable:create')
|
||||
@GlobalScope('variable:create')
|
||||
async createVariable(req: VariablesRequest.Create) {
|
||||
const variable = req.body;
|
||||
delete variable.id;
|
||||
|
@ -45,7 +45,7 @@ export class VariablesController {
|
|||
}
|
||||
|
||||
@Get('/:id')
|
||||
@RequireGlobalScope('variable:read')
|
||||
@GlobalScope('variable:read')
|
||||
async getVariable(req: VariablesRequest.Get) {
|
||||
const id = req.params.id;
|
||||
const variable = await this.variablesService.getCached(id);
|
||||
|
@ -57,7 +57,7 @@ export class VariablesController {
|
|||
|
||||
@Patch('/:id')
|
||||
@Licensed('feat:variables')
|
||||
@RequireGlobalScope('variable:update')
|
||||
@GlobalScope('variable:update')
|
||||
async updateVariable(req: VariablesRequest.Update) {
|
||||
const id = req.params.id;
|
||||
const variable = req.body;
|
||||
|
@ -75,7 +75,7 @@ export class VariablesController {
|
|||
}
|
||||
|
||||
@Delete('/:id(\\w+)')
|
||||
@RequireGlobalScope('variable:delete')
|
||||
@GlobalScope('variable:delete')
|
||||
async deleteVariable(req: VariablesRequest.Delete) {
|
||||
const id = req.params.id;
|
||||
await this.variablesService.delete(id);
|
||||
|
|
|
@ -5,7 +5,7 @@ import type {
|
|||
} from 'n8n-workflow';
|
||||
import { MessageEventBusDestinationTypeNames } from 'n8n-workflow';
|
||||
|
||||
import { RestController, Get, Post, Delete, Authorized, RequireGlobalScope } from '@/decorators';
|
||||
import { RestController, Get, Post, Delete, Authorized, GlobalScope } from '@/decorators';
|
||||
import { AuthenticatedRequest } from '@/requests';
|
||||
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
||||
|
||||
|
@ -62,7 +62,7 @@ export class EventBusControllerEE {
|
|||
// ----------------------------------------
|
||||
|
||||
@Get('/destination', { middlewares: [logStreamingLicensedMiddleware] })
|
||||
@RequireGlobalScope('eventBusDestination:list')
|
||||
@GlobalScope('eventBusDestination:list')
|
||||
async getDestination(req: express.Request): Promise<MessageEventBusDestinationOptions[]> {
|
||||
if (isWithIdString(req.query)) {
|
||||
return await this.eventBus.findDestination(req.query.id);
|
||||
|
@ -72,7 +72,7 @@ export class EventBusControllerEE {
|
|||
}
|
||||
|
||||
@Post('/destination', { middlewares: [logStreamingLicensedMiddleware] })
|
||||
@RequireGlobalScope('eventBusDestination:create')
|
||||
@GlobalScope('eventBusDestination:create')
|
||||
async postDestination(req: AuthenticatedRequest): Promise<any> {
|
||||
let result: MessageEventBusDestination | undefined;
|
||||
if (isMessageEventBusDestinationOptions(req.body)) {
|
||||
|
@ -116,7 +116,7 @@ export class EventBusControllerEE {
|
|||
}
|
||||
|
||||
@Get('/testmessage', { middlewares: [logStreamingLicensedMiddleware] })
|
||||
@RequireGlobalScope('eventBusDestination:test')
|
||||
@GlobalScope('eventBusDestination:test')
|
||||
async sendTestMessage(req: express.Request): Promise<boolean> {
|
||||
if (isWithIdString(req.query)) {
|
||||
return await this.eventBus.testDestination(req.query.id);
|
||||
|
@ -125,7 +125,7 @@ export class EventBusControllerEE {
|
|||
}
|
||||
|
||||
@Delete('/destination', { middlewares: [logStreamingLicensedMiddleware] })
|
||||
@RequireGlobalScope('eventBusDestination:delete')
|
||||
@GlobalScope('eventBusDestination:delete')
|
||||
async deleteDestination(req: AuthenticatedRequest) {
|
||||
if (isWithIdString(req.query)) {
|
||||
return await this.eventBus.removeDestination(req.query.id);
|
||||
|
|
|
@ -2,7 +2,7 @@ import express from 'express';
|
|||
import type { IRunExecutionData } from 'n8n-workflow';
|
||||
import { EventMessageTypeNames } from 'n8n-workflow';
|
||||
|
||||
import { RestController, Get, Post, Authorized, RequireGlobalScope } from '@/decorators';
|
||||
import { RestController, Get, Post, Authorized, GlobalScope } from '@/decorators';
|
||||
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
||||
|
||||
import { isEventMessageOptions } from './EventMessageClasses/AbstractEventMessage';
|
||||
|
@ -45,7 +45,7 @@ export class EventBusController {
|
|||
// Events
|
||||
// ----------------------------------------
|
||||
@Get('/event')
|
||||
@RequireGlobalScope('eventBusEvent:query')
|
||||
@GlobalScope('eventBusEvent:query')
|
||||
async getEvents(
|
||||
req: express.Request,
|
||||
): Promise<EventMessageTypes[] | Record<string, EventMessageTypes[]>> {
|
||||
|
@ -67,14 +67,14 @@ export class EventBusController {
|
|||
}
|
||||
|
||||
@Get('/failed')
|
||||
@RequireGlobalScope('eventBusEvent:list')
|
||||
@GlobalScope('eventBusEvent:list')
|
||||
async getFailedEvents(req: express.Request): Promise<FailedEventSummary[]> {
|
||||
const amount = parseInt(req.query?.amount as string) ?? 5;
|
||||
return await this.eventBus.getEventsFailed(amount);
|
||||
}
|
||||
|
||||
@Get('/execution/:id')
|
||||
@RequireGlobalScope('eventBusEvent:read')
|
||||
@GlobalScope('eventBusEvent:read')
|
||||
async getEventForExecutionId(req: express.Request): Promise<EventMessageTypes[] | undefined> {
|
||||
if (req.params?.id) {
|
||||
let logHistory;
|
||||
|
@ -87,7 +87,7 @@ export class EventBusController {
|
|||
}
|
||||
|
||||
@Get('/execution-recover/:id')
|
||||
@RequireGlobalScope('eventBusEvent:read')
|
||||
@GlobalScope('eventBusEvent:read')
|
||||
async getRecoveryForExecutionId(req: express.Request): Promise<IRunExecutionData | undefined> {
|
||||
const { id } = req.params;
|
||||
if (req.params?.id) {
|
||||
|
@ -102,7 +102,7 @@ export class EventBusController {
|
|||
}
|
||||
|
||||
@Post('/event')
|
||||
@RequireGlobalScope('eventBusEvent:create')
|
||||
@GlobalScope('eventBusEvent:create')
|
||||
async postEvent(req: express.Request): Promise<EventMessageTypes | undefined> {
|
||||
let msg: EventMessageTypes | undefined;
|
||||
if (isEventMessageOptions(req.body)) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Authorized, Get, Post, RequireGlobalScope, RestController } from '@/decorators';
|
||||
import { Authorized, Get, Post, GlobalScope, RestController } from '@/decorators';
|
||||
import { LicenseRequest } from '@/requests';
|
||||
import { LicenseService } from './license.service';
|
||||
|
||||
|
@ -13,7 +13,7 @@ export class LicenseController {
|
|||
}
|
||||
|
||||
@Post('/activate')
|
||||
@RequireGlobalScope('license:manage')
|
||||
@GlobalScope('license:manage')
|
||||
async activateLicense(req: LicenseRequest.Activate) {
|
||||
const { activationKey } = req.body;
|
||||
await this.licenseService.activateLicense(activationKey);
|
||||
|
@ -21,7 +21,7 @@ export class LicenseController {
|
|||
}
|
||||
|
||||
@Post('/renew')
|
||||
@RequireGlobalScope('license:manage')
|
||||
@GlobalScope('license:manage')
|
||||
async renewLicense() {
|
||||
await this.licenseService.renewLicense();
|
||||
return await this.getTokenAndData();
|
||||
|
|
|
@ -3,14 +3,7 @@ import { validate } from 'class-validator';
|
|||
import type { PostBindingContext } from 'samlify/types/src/entity';
|
||||
import url from 'url';
|
||||
|
||||
import {
|
||||
Authorized,
|
||||
Get,
|
||||
NoAuthRequired,
|
||||
Post,
|
||||
RestController,
|
||||
RequireGlobalScope,
|
||||
} from '@/decorators';
|
||||
import { Authorized, Get, NoAuthRequired, Post, RestController, GlobalScope } from '@/decorators';
|
||||
|
||||
import { AuthService } from '@/auth/auth.service';
|
||||
import { AuthenticatedRequest } from '@/requests';
|
||||
|
@ -76,7 +69,7 @@ export class SamlController {
|
|||
* Set SAML config
|
||||
*/
|
||||
@Post(SamlUrls.config, { middlewares: [samlLicensedMiddleware] })
|
||||
@RequireGlobalScope('saml:manage')
|
||||
@GlobalScope('saml:manage')
|
||||
async configPost(req: SamlConfiguration.Update) {
|
||||
const validationResult = await validate(req.body);
|
||||
if (validationResult.length === 0) {
|
||||
|
@ -95,7 +88,7 @@ export class SamlController {
|
|||
* Set SAML config
|
||||
*/
|
||||
@Post(SamlUrls.configToggleEnabled, { middlewares: [samlLicensedMiddleware] })
|
||||
@RequireGlobalScope('saml:manage')
|
||||
@GlobalScope('saml:manage')
|
||||
async toggleEnabledPost(req: SamlConfiguration.Toggle, res: express.Response) {
|
||||
if (req.body.loginEnabled === undefined) {
|
||||
throw new BadRequestError('Body should contain a boolean "loginEnabled" property');
|
||||
|
@ -211,7 +204,7 @@ export class SamlController {
|
|||
* This endpoint is available if SAML is licensed and the requestor is an instance owner
|
||||
*/
|
||||
@Get(SamlUrls.configTest, { middlewares: [samlLicensedMiddleware] })
|
||||
@RequireGlobalScope('saml:manage')
|
||||
@GlobalScope('saml:manage')
|
||||
async configTestGet(req: AuthenticatedRequest, res: express.Response) {
|
||||
return await this.handleInitSSO(res, getServiceProviderConfigTestReturnUrl());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue