mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 18:41:14 +00:00
feat(core): Add scopes to API Keys (#14176)
Co-authored-by: Charlie Kolb <charlie@n8n.io> Co-authored-by: Danny Martini <danny@n8n.io>
This commit is contained in:
@@ -6,7 +6,11 @@ import { VariablesController } from '@/environments.ee/variables/variables.contr
|
||||
import type { PaginatedRequest } from '@/public-api/types';
|
||||
import type { VariablesRequest } from '@/requests';
|
||||
|
||||
import { globalScope, isLicensed, validCursor } from '../../shared/middlewares/global.middleware';
|
||||
import {
|
||||
apiKeyHasScopeWithGlobalScopeFallback,
|
||||
isLicensed,
|
||||
validCursor,
|
||||
} from '../../shared/middlewares/global.middleware';
|
||||
import { encodeNextCursor } from '../../shared/services/pagination.service';
|
||||
|
||||
type Create = VariablesRequest.Create;
|
||||
@@ -16,7 +20,7 @@ type GetAll = PaginatedRequest;
|
||||
export = {
|
||||
createVariable: [
|
||||
isLicensed('feat:variables'),
|
||||
globalScope('variable:create'),
|
||||
apiKeyHasScopeWithGlobalScopeFallback({ scope: 'variable:create' }),
|
||||
async (req: Create, res: Response) => {
|
||||
await Container.get(VariablesController).createVariable(req);
|
||||
|
||||
@@ -25,7 +29,7 @@ export = {
|
||||
],
|
||||
deleteVariable: [
|
||||
isLicensed('feat:variables'),
|
||||
globalScope('variable:delete'),
|
||||
apiKeyHasScopeWithGlobalScopeFallback({ scope: 'variable:delete' }),
|
||||
async (req: Delete, res: Response) => {
|
||||
await Container.get(VariablesController).deleteVariable(req);
|
||||
|
||||
@@ -34,7 +38,7 @@ export = {
|
||||
],
|
||||
getVariables: [
|
||||
isLicensed('feat:variables'),
|
||||
globalScope('variable:list'),
|
||||
apiKeyHasScopeWithGlobalScopeFallback({ scope: 'variable:list' }),
|
||||
validCursor,
|
||||
async (req: GetAll, res: Response) => {
|
||||
const { offset = 0, limit = 100 } = req.query;
|
||||
|
||||
Reference in New Issue
Block a user