diff --git a/packages/hoppscotch-backend/src/admin/infra.resolver.ts b/packages/hoppscotch-backend/src/admin/infra.resolver.ts index 5cb2541ea..d9127922e 100644 --- a/packages/hoppscotch-backend/src/admin/infra.resolver.ts +++ b/packages/hoppscotch-backend/src/admin/infra.resolver.ts @@ -260,6 +260,7 @@ export class InfraResolver { @Query(() => [String], { description: 'Allowed Auth Provider list', }) + @UseGuards(GqlAuthGuard, GqlAdminGuard) allowedAuthProviders() { return this.infraConfigService.getAllowedAuthProviders(); } diff --git a/packages/hoppscotch-backend/src/auth/auth.controller.ts b/packages/hoppscotch-backend/src/auth/auth.controller.ts index 8aa102bbe..27534d003 100644 --- a/packages/hoppscotch-backend/src/auth/auth.controller.ts +++ b/packages/hoppscotch-backend/src/auth/auth.controller.ts @@ -40,6 +40,12 @@ export class AuthController { private configService: ConfigService, ) {} + @Get('providers') + async getAuthProviders() { + const providers = await this.authService.getAuthProviders(); + return { providers }; + } + /** ** Route to initiate magic-link auth for a users email */ diff --git a/packages/hoppscotch-backend/src/auth/auth.module.ts b/packages/hoppscotch-backend/src/auth/auth.module.ts index 5fa5b018e..ccfadbff8 100644 --- a/packages/hoppscotch-backend/src/auth/auth.module.ts +++ b/packages/hoppscotch-backend/src/auth/auth.module.ts @@ -13,6 +13,7 @@ import { MicrosoftStrategy } from './strategies/microsoft.strategy'; import { AuthProvider, authProviderCheck } from './helper'; import { ConfigModule, ConfigService } from '@nestjs/config'; import { loadInfraConfiguration } from 'src/infra-config/helper'; +import { InfraConfigModule } from 'src/infra-config/infra-config.module'; @Module({ imports: [ @@ -26,6 +27,7 @@ import { loadInfraConfiguration } from 'src/infra-config/helper'; secret: configService.get('JWT_SECRET'), }), }), + InfraConfigModule, ], providers: [AuthService, JwtStrategy, RTJwtStrategy], controllers: [AuthController], diff --git a/packages/hoppscotch-backend/src/auth/auth.service.ts b/packages/hoppscotch-backend/src/auth/auth.service.ts index bff587b4c..12db5c328 100644 --- a/packages/hoppscotch-backend/src/auth/auth.service.ts +++ b/packages/hoppscotch-backend/src/auth/auth.service.ts @@ -29,6 +29,7 @@ import { AuthUser, IsAdmin } from 'src/types/AuthUser'; import { VerificationToken } from '@prisma/client'; import { Origin } from './helper'; import { ConfigService } from '@nestjs/config'; +import { InfraConfigService } from 'src/infra-config/infra-config.service'; @Injectable() export class AuthService { @@ -38,6 +39,7 @@ export class AuthService { private jwtService: JwtService, private readonly mailerService: MailerService, private readonly configService: ConfigService, + private infraConfigService: InfraConfigService, ) {} /** @@ -381,4 +383,8 @@ export class AuthService { return E.right({ isAdmin: false }); } + + getAuthProviders() { + return this.infraConfigService.getAllowedAuthProviders(); + } }