diff --git a/packages/hoppscotch-backend/src/auth/helper.ts b/packages/hoppscotch-backend/src/auth/helper.ts index 0f58b8be..d6e81bf7 100644 --- a/packages/hoppscotch-backend/src/auth/helper.ts +++ b/packages/hoppscotch-backend/src/auth/helper.ts @@ -27,6 +27,7 @@ export enum AuthProvider { GITHUB = 'GITHUB', MICROSOFT = 'MICROSOFT', EMAIL = 'EMAIL', + LOCAL = 'LOCAL', } /** diff --git a/packages/hoppscotch-backend/src/infra-config/helper.ts b/packages/hoppscotch-backend/src/infra-config/helper.ts index b2171817..3a6f86b4 100644 --- a/packages/hoppscotch-backend/src/infra-config/helper.ts +++ b/packages/hoppscotch-backend/src/infra-config/helper.ts @@ -66,6 +66,7 @@ export function getAuthProviderRequiredKeys( InfraConfigEnum.MICROSOFT_SCOPE, InfraConfigEnum.MICROSOFT_TENANT, ], + [AuthProvider.LOCAL]: [], [AuthProvider.EMAIL]: env['INFRA'].MAILER_USE_CUSTOM_CONFIGS === 'true' ? [ diff --git a/packages/hoppscotch-backend/src/infra-config/infra-config.service.spec.ts b/packages/hoppscotch-backend/src/infra-config/infra-config.service.spec.ts index bac79540..cc579125 100644 --- a/packages/hoppscotch-backend/src/infra-config/infra-config.service.spec.ts +++ b/packages/hoppscotch-backend/src/infra-config/infra-config.service.spec.ts @@ -16,6 +16,7 @@ import { PubSubService } from 'src/pubsub/pubsub.service'; import { ServiceStatus } from './helper'; import * as E from 'fp-ts/Either'; import { UserService } from 'src/user/user.service'; +import { AuthProvider } from 'src/auth/helper'; const mockPrisma = mockDeep(); const mockConfigService = mockDeep(); @@ -295,6 +296,19 @@ describe('InfraConfigService', () => { }); describe('validateEnvValues', () => { + describe('VITE_ALLOWED_AUTH_PROVIDERS', () => { + it('should accept LOCAL in VITE_ALLOWED_AUTH_PROVIDERS', () => { + const result = infraConfigService.validateEnvValues([ + { + name: InfraConfigEnum.VITE_ALLOWED_AUTH_PROVIDERS, + value: 'LOCAL', + }, + ]); + + expect(result).toEqualRight(true); + }); + }); + describe('MAILER_SMTP_AUTH_TYPE', () => { it('should accept an empty value (defaults to login at runtime)', () => { const result = infraConfigService.validateEnvValues([ @@ -348,6 +362,17 @@ describe('InfraConfigService', () => { }); }); + describe('isServiceConfigured', () => { + it('should consider LOCAL configured without external config', () => { + const result = infraConfigService.isServiceConfigured( + AuthProvider.LOCAL, + {}, + ); + + expect(result).toBe(true); + }); + }); + describe('getOnboardingConfig', () => { const RECOVERY_TOKEN = 'valid-recovery-token-123'; diff --git a/packages/hoppscotch-backend/src/infra-config/infra-config.service.ts b/packages/hoppscotch-backend/src/infra-config/infra-config.service.ts index 601d5ebb..d66578ef 100644 --- a/packages/hoppscotch-backend/src/infra-config/infra-config.service.ts +++ b/packages/hoppscotch-backend/src/infra-config/infra-config.service.ts @@ -321,6 +321,8 @@ export class InfraConfigService implements OnModuleInit, OnModuleDestroy { } else { return configMap.MAILER_SMTP_URL && configMap.MAILER_ADDRESS_FROM; } + case AuthProvider.LOCAL: + return true; default: return false; }