diff --git a/package-lock.json b/package-lock.json index b093142..199f001 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@aws-sdk/client-secrets-manager": "^3.112.0", "@dadosfera/dadosfera-logs": "^1.0.0-beta.3", - "@dadosfera/protospack-v2": "3.10.0", + "@dadosfera/protospack-v2": "3.11.0-beta.4", "@grpc/grpc-js": "^1.6.7", "@grpc/proto-loader": "^0.6.13", "@nestjs/common": "^8.4.7", @@ -1723,9 +1723,9 @@ } }, "node_modules/@dadosfera/protospack-v2": { - "version": "3.10.0", - "resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.10.0.tgz", - "integrity": "sha512-XPfRh2R2zZtN/MRxAwbC994xDJftRlnl3w2vqPGMt996tJCpZkedzdH1hHdqer68QDIMM5td0OpW/Gs8K1H07A==", + "version": "3.11.0-beta.4", + "resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.11.0-beta.4.tgz", + "integrity": "sha512-TbRiEkSh7TJXHPiwOD+k22gDV2YIkjL6rSlNzqRTpeWo7Qp3gdkNIiWhUKUMeSIJyeJ9Qo1OKyvE8N/MWfRxKQ==", "dependencies": { "@grpc/grpc-js": "^1.6.7", "rxjs": "^7.5.5", @@ -12287,9 +12287,9 @@ } }, "@dadosfera/protospack-v2": { - "version": "3.10.0", - "resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.10.0.tgz", - "integrity": "sha512-XPfRh2R2zZtN/MRxAwbC994xDJftRlnl3w2vqPGMt996tJCpZkedzdH1hHdqer68QDIMM5td0OpW/Gs8K1H07A==", + "version": "3.11.0-beta.4", + "resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.11.0-beta.4.tgz", + "integrity": "sha512-TbRiEkSh7TJXHPiwOD+k22gDV2YIkjL6rSlNzqRTpeWo7Qp3gdkNIiWhUKUMeSIJyeJ9Qo1OKyvE8N/MWfRxKQ==", "requires": { "@grpc/grpc-js": "^1.6.7", "rxjs": "^7.5.5", diff --git a/package.json b/package.json index 3b5ed08..0534f25 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "passport-hubspot-oauth2": "^1.0.3", "passport-mailchimp": "^1.1.0", "protospack": "2.5.2", - "@dadosfera/protospack-v2": "3.10.0", + "@dadosfera/protospack-v2": "3.11.0-beta.4", "reflect-metadata": "^0.1.13", "rimraf": "^3.0.2", "rxjs": "^7.5.5", diff --git a/src/modules/auth/auth.controller.ts b/src/modules/auth/auth.controller.ts index e664c96..427077a 100644 --- a/src/modules/auth/auth.controller.ts +++ b/src/modules/auth/auth.controller.ts @@ -7,6 +7,7 @@ import { HttpStatus, Inject, UseFilters, + Query, } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { @@ -21,9 +22,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 +46,21 @@ export class AuthController { this.logger = dadosferaLogger.logger; } + @Post('/sso/snowflake') + @RequireAllPermissions(PERMISSIONS.SNOWFLAKE.permissions.OPEN) + @HttpCode(HttpStatus.OK) + async snowflakeSignIn( + @User() user: RequestUser, + @Body('RelayState') relayState: string, + ) { + this.logger.info('/auth - snowflakeSignIn'); + + return this.authClient.snowflakeSignIn({ + userId: user.user_id, + relayState, + }); + } + @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');