mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-19 11:01:15 +00:00
32 lines
873 B
TypeScript
32 lines
873 B
TypeScript
import type { RequestHandler } from 'express';
|
|
import type { AuthenticatedRequest } from '../../../requests';
|
|
import { isSamlLicensed, isSamlLicensedAndEnabled } from '../samlHelpers';
|
|
|
|
export const samlLicensedOwnerMiddleware: RequestHandler = (
|
|
req: AuthenticatedRequest,
|
|
res,
|
|
next,
|
|
) => {
|
|
if (isSamlLicensed() && req.user?.globalRole.name === 'owner') {
|
|
next();
|
|
} else {
|
|
res.status(401).json({ status: 'error', message: 'Unauthorized' });
|
|
}
|
|
};
|
|
|
|
export const samlLicensedAndEnabledMiddleware: RequestHandler = (req, res, next) => {
|
|
if (isSamlLicensedAndEnabled()) {
|
|
next();
|
|
} else {
|
|
res.status(401).json({ status: 'error', message: 'Unauthorized' });
|
|
}
|
|
};
|
|
|
|
export const samlLicensedMiddleware: RequestHandler = (req, res, next) => {
|
|
if (isSamlLicensed()) {
|
|
next();
|
|
} else {
|
|
res.status(401).json({ status: 'error', message: 'Unauthorized' });
|
|
}
|
|
};
|