mirror of
https://github.com/stonith404/pingvin-share.git
synced 2025-01-15 01:14:27 -05:00
fix: improve oidc error logging
This commit is contained in:
parent
3d2b978daf
commit
dee70987eb
1 changed files with 10 additions and 4 deletions
|
@ -1,13 +1,13 @@
|
||||||
import { Logger } from "@nestjs/common";
|
import { InternalServerErrorException, Logger } from "@nestjs/common";
|
||||||
import { ConfigService } from "../../config/config.service";
|
|
||||||
import { JwtService } from "@nestjs/jwt";
|
import { JwtService } from "@nestjs/jwt";
|
||||||
import { Cache } from "cache-manager";
|
import { Cache } from "cache-manager";
|
||||||
import * as jmespath from "jmespath";
|
import * as jmespath from "jmespath";
|
||||||
import { nanoid } from "nanoid";
|
import { nanoid } from "nanoid";
|
||||||
|
import { ConfigService } from "../../config/config.service";
|
||||||
import { OAuthCallbackDto } from "../dto/oauthCallback.dto";
|
import { OAuthCallbackDto } from "../dto/oauthCallback.dto";
|
||||||
import { OAuthProvider, OAuthToken } from "./oauthProvider.interface";
|
|
||||||
import { OAuthSignInDto } from "../dto/oauthSignIn.dto";
|
import { OAuthSignInDto } from "../dto/oauthSignIn.dto";
|
||||||
import { ErrorPageException } from "../exceptions/errorPage.exception";
|
import { ErrorPageException } from "../exceptions/errorPage.exception";
|
||||||
|
import { OAuthProvider, OAuthToken } from "./oauthProvider.interface";
|
||||||
|
|
||||||
export abstract class GenericOidcProvider implements OAuthProvider<OidcToken> {
|
export abstract class GenericOidcProvider implements OAuthProvider<OidcToken> {
|
||||||
protected discoveryUri: string;
|
protected discoveryUri: string;
|
||||||
|
@ -116,7 +116,13 @@ export abstract class GenericOidcProvider implements OAuthProvider<OidcToken> {
|
||||||
},
|
},
|
||||||
): Promise<OAuthSignInDto> {
|
): Promise<OAuthSignInDto> {
|
||||||
const idTokenData = this.decodeIdToken(token.idToken);
|
const idTokenData = this.decodeIdToken(token.idToken);
|
||||||
// maybe it's not necessary to verify the id token since it's directly obtained from the provider
|
|
||||||
|
if (!idTokenData) {
|
||||||
|
this.logger.error(
|
||||||
|
`Can not get ID Token from response ${JSON.stringify(token.rawToken, undefined, 2)}`,
|
||||||
|
);
|
||||||
|
throw new InternalServerErrorException();
|
||||||
|
}
|
||||||
|
|
||||||
const key = `oauth-${this.name}-nonce-${query.state}`;
|
const key = `oauth-${this.name}-nonce-${query.state}`;
|
||||||
const nonce = await this.cache.get(key);
|
const nonce = await this.cache.get(key);
|
||||||
|
|
Loading…
Add table
Reference in a new issue