Skip to content

Commit 06b8126

Browse files
authored
fix: update loginmethod endpoints (#5681)
* fix: disable loginmethod read, create, and update endpoints in cloud * fix: refactor * fix: status code * fix: duplicated code and unused imports
1 parent af81d87 commit 06b8126

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

packages/server/src/enterprise/controllers/login-method.controller.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,16 @@ import GoogleSSO from '../sso/GoogleSSO'
1414
import { decrypt } from '../utils/encryption.util'
1515

1616
export class LoginMethodController {
17+
private assertEnterprisePlatform(): void {
18+
const platformType = getRunningExpressApp().identityManager.getPlatformType()
19+
if (platformType === Platform.CLOUD || platformType === Platform.OPEN_SOURCE) {
20+
throw new InternalFlowiseError(StatusCodes.FORBIDDEN, GeneralErrorMessage.FORBIDDEN)
21+
}
22+
}
23+
1724
public async create(req: Request, res: Response, next: NextFunction) {
1825
try {
26+
this.assertEnterprisePlatform()
1927
const loginMethodService = new LoginMethodService()
2028
const loginMethod = await loginMethodService.createLoginMethod(req.body)
2129
return res.status(StatusCodes.CREATED).json(loginMethod)
@@ -64,6 +72,7 @@ export class LoginMethodController {
6472
public async read(req: Request, res: Response, next: NextFunction) {
6573
let queryRunner
6674
try {
75+
this.assertEnterprisePlatform()
6776
queryRunner = getRunningExpressApp().AppDataSource.createQueryRunner()
6877
await queryRunner.connect()
6978
const query = req.query as Partial<LoginMethod>
@@ -102,6 +111,7 @@ export class LoginMethodController {
102111
}
103112
public async update(req: Request, res: Response, next: NextFunction) {
104113
try {
114+
this.assertEnterprisePlatform()
105115
const loginMethodService = new LoginMethodService()
106116
const loginMethod = await loginMethodService.createOrUpdateConfig(req.body)
107117
if (loginMethod?.status === 'OK' && loginMethod?.organizationId) {

packages/server/src/utils/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export const WHITELIST_URLS = [
5757
export const API_KEY_BLACKLIST_URLS = ['/api/v1/nvidia-nim']
5858

5959
export const enum GeneralErrorMessage {
60+
FORBIDDEN = 'Forbidden',
6061
UNAUTHORIZED = 'Unauthorized',
6162
UNHANDLED_EDGE_CASE = 'Unhandled Edge Case',
6263
INVALID_PASSWORD = 'Invalid Password',

0 commit comments

Comments
 (0)