mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-16 06:49:09 +00:00
FIX: auth callback
This commit is contained in:
@@ -122,11 +122,14 @@ export class IdentityProviderController {
|
||||
return await this.identityProviderService.updateIdentityProviders(id, body, metadata);
|
||||
}
|
||||
|
||||
@Get('/callback')
|
||||
@Post('/callback')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
async callbackIdp(@Req() req: Request) {
|
||||
async callbackIdp(@Req() req: Request, @Body() body: {
|
||||
state: string,
|
||||
code: string
|
||||
}) {
|
||||
this.logger.info('GET /identity-providers/callback');
|
||||
const { code, state } = req.query;
|
||||
const { code, state } = body;
|
||||
|
||||
if (!code) {
|
||||
this.logger.error('No code received from IDP');
|
||||
@@ -138,7 +141,7 @@ export class IdentityProviderController {
|
||||
throw new Error(ErrorCodes.IDENTITY_PROVIDER.INVALID_RESPONSE);
|
||||
}
|
||||
|
||||
return await this.identityProviderService.getTokenByIdp(req);
|
||||
return await this.identityProviderService.getTokenByIdp(code, state);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
|
||||
@@ -95,8 +95,8 @@ export class IdentityProviderService implements OnModuleInit {
|
||||
return COGNITO_ISSUER_URL;
|
||||
}
|
||||
|
||||
async getTokenByIdp(req: Request) {
|
||||
const ssoSign = await this.cacheService.get(req.query.state as string);
|
||||
async getTokenByIdp(code: string, state: string) {
|
||||
const ssoSign = await this.cacheService.get(state);
|
||||
|
||||
if (!ssoSign) {
|
||||
throw new BadRequestException('SSO sign-in is expired or not found');
|
||||
@@ -115,7 +115,7 @@ export class IdentityProviderService implements OnModuleInit {
|
||||
throw new BadRequestException('SSO sign-in is expired or not found');
|
||||
}
|
||||
|
||||
const params = client.callbackParams(req)
|
||||
const params = client.callbackParams(`${callbackUrl}?code=${code}&state=${state}`);
|
||||
const tokenSet = await client.callback(
|
||||
callbackUrl,
|
||||
params,
|
||||
|
||||
Reference in New Issue
Block a user