Skip to content

Commit 7c380fb

Browse files
committed
Add support for custom JWKS URI in auth module
1 parent 7710f05 commit 7c380fb

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/auth.module.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,15 @@ export class AuthModule {
4343
{
4444
provide: 'JwtGuard',
4545
useFactory: async (reflector: Reflector) => {
46-
const { rolesMapping, authProvider, realm } = options;
47-
const oidc = await getOpenIdConfiguration(authProvider, realm);
46+
const { rolesMapping, authProvider, realm, jwksUri } = options;
47+
let jwks_uri = jwksUri;
4848

49-
const jwks = await getJwks(oidc.jwks_uri);
49+
if (!jwks_uri) {
50+
const oidc = await getOpenIdConfiguration(authProvider!, realm);
51+
jwks_uri = oidc.jwks_uri;
52+
}
53+
54+
const jwks = await getJwks(jwks_uri);
5055

5156
const sigKey = jwks.keys.find((item) => item.use === 'sig');
5257
const x5cArray = sigKey?.x5c || [];

src/auth.types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export type AuthOptions = {
2-
authProvider: string;
2+
authProvider?: string;
3+
jwksUri?: string;
34
realm: string;
45
rolesMapping: string;
56
};

0 commit comments

Comments
 (0)