diff --git a/src/modules/auth/auth.controller.ts b/src/modules/auth/auth.controller.ts index e664c96..078e9fc 100644 --- a/src/modules/auth/auth.controller.ts +++ b/src/modules/auth/auth.controller.ts @@ -21,9 +21,15 @@ import { AuthVerifyTotpMfaRequest, } from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/messages'; +import { PERMISSIONS } from 'src/authentication/permissions.enum'; +import { + Authenticated, + RequireAllPermissions, +} from 'src/authentication/authentication.decorator'; import { AuthClientService } from './auth.service'; import { DadosferaLogger } from '@dadosfera/dadosfera-logs'; import { GrpcToHttpExceptionFilter } from '../../error/grpc-to-http-exception.filter'; +import { RequestUser, User } from 'src/authentication/user.decorator'; @ApiTags('Auth') @UseFilters(new GrpcToHttpExceptionFilter()) @@ -39,6 +45,15 @@ export class AuthController { this.logger = dadosferaLogger.logger; } + @Post('/sso/snowflake') + @RequireAllPermissions(PERMISSIONS.SNOWFLAKE.permissions.OPEN) + @HttpCode(HttpStatus.OK) + async snowflakeSignIn(@User() user: RequestUser) { + this.logger.info('/auth - snowflakeSignIn'); + + return this.authClient.snowflakeSignIn({ userId: user.user_id }); + } + @Post('sign-in') @HttpCode(HttpStatus.OK) async signIn(@Body() { username, password, totp }: AuthSignInRequest) { diff --git a/src/modules/auth/auth.service.ts b/src/modules/auth/auth.service.ts index 0da58eb..ba8b2a4 100644 --- a/src/modules/auth/auth.service.ts +++ b/src/modules/auth/auth.service.ts @@ -6,6 +6,7 @@ import { lastValueFrom } from 'rxjs'; import { ProtoServices } from '@dadosfera/protospack-v2/dist/lib/Duc'; import { AuthProtoService as AuthServiceInterface } from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/write-service'; import { + AuthSnowflakeSignInRequest, AuthSignInRequest, AuthRefreshAccessTokenRequest, AuthEnableTotpMfaRequest, @@ -43,6 +44,12 @@ export class AuthClientService implements OnModuleInit { return lastValueFrom(this.authService.AuthGetPublicKeys({})); } + async snowflakeSignIn(input: AuthSnowflakeSignInRequest) { + this.logger.info('snowflakeSignIn'); + + return lastValueFrom(this.authService.AuthSnowflakeSignIn(input)); + } + async signIn({ username, password, totp }: AuthSignInRequest) { this.logger.info('SignIn');