Skip to content

Commit 2a6d734

Browse files
committed
Added strategy name for keycloak
1 parent 7cb3142 commit 2a6d734

File tree

5 files changed

+24
-16
lines changed

5 files changed

+24
-16
lines changed

src/component.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,23 @@ import {
99
} from './providers';
1010
import {
1111
AuthStrategyProvider,
12+
AzureADAuthStrategyFactoryProvider,
13+
AzureADAuthVerifyProvider,
14+
BearerStrategyFactoryProvider,
15+
BearerTokenVerifyProvider,
1216
ClientAuthStrategyProvider,
17+
ClientPasswordStrategyFactoryProvider,
1318
ClientPasswordVerifyProvider,
14-
LocalPasswordVerifyProvider,
15-
BearerTokenVerifyProvider,
16-
ResourceOwnerVerifyProvider,
19+
GoogleAuthStrategyFactoryProvider,
20+
GoogleAuthVerifyProvider,
21+
KeycloakStrategyFactoryProvider,
22+
KeycloakVerifyProvider,
1723
LocalPasswordStrategyFactoryProvider,
18-
ClientPasswordStrategyFactoryProvider,
19-
BearerStrategyFactoryProvider,
24+
LocalPasswordVerifyProvider,
2025
ResourceOwnerPasswordStrategyFactoryProvider,
26+
ResourceOwnerVerifyProvider,
2127
} from './strategies';
2228
import {Strategies} from './strategies/keys';
23-
import {
24-
GoogleAuthStrategyFactoryProvider,
25-
GoogleAuthVerifyProvider,
26-
} from './strategies/passport/passport-google-oauth2';
27-
28-
import {
29-
AzureADAuthStrategyFactoryProvider,
30-
AzureADAuthVerifyProvider,
31-
} from './strategies/passport/passport-azure-ad';
3229

3330
export class AuthenticationComponent implements Component {
3431
constructor() {
@@ -54,6 +51,8 @@ export class AuthenticationComponent implements Component {
5451
.key]: GoogleAuthStrategyFactoryProvider,
5552
[Strategies.Passport.AZURE_AD_STRATEGY_FACTORY
5653
.key]: AzureADAuthStrategyFactoryProvider,
54+
[Strategies.Passport.KEYCLOAK_STRATEGY_FACTORY
55+
.key]: KeycloakStrategyFactoryProvider,
5756

5857
// Verifier functions
5958
[Strategies.Passport.OAUTH2_CLIENT_PASSWORD_VERIFIER
@@ -67,6 +66,7 @@ export class AuthenticationComponent implements Component {
6766
[Strategies.Passport.GOOGLE_OAUTH2_VERIFIER
6867
.key]: GoogleAuthVerifyProvider,
6968
[Strategies.Passport.AZURE_AD_VERIFIER.key]: AzureADAuthVerifyProvider,
69+
[Strategies.Passport.KEYCLOAK_VERIFIER.key]: KeycloakVerifyProvider,
7070
};
7171
}
7272

src/strategies/passport/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ export * from './passport-client-password';
33
export * from './passport-local';
44
export * from './passport-resource-owner-password';
55
export * from './passport-keycloak';
6+
export * from './passport-google-oauth2';
7+
export * from './passport-azure-ad';

src/strategies/passport/passport-keycloak/keycloak-strategy-factory-provider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ export class KeycloakStrategyFactoryProvider
2121
) {}
2222

2323
value(): KeycloakStrategyFactory {
24-
return (options) => this.getGoogleAuthStrategyVerifier(options);
24+
return (options) => this.getKeycloakAuthStrategyVerifier(options);
2525
}
2626

2727
// eslint-disable-next-line @typescript-eslint/no-explicit-any
28-
getGoogleAuthStrategyVerifier(options: any): typeof KeycloakStrategy {
28+
getKeycloakAuthStrategyVerifier(options: any): typeof KeycloakStrategy {
2929
return new KeycloakStrategy(
3030
options,
3131
async (

src/strategies/user-auth-strategy.provider.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
ResourceOwnerPasswordStrategyFactory,
1818
} from './passport/passport-resource-owner-password';
1919
import {AzureADAuthStrategyFactory} from './passport/passport-azure-ad';
20+
import {KeycloakStrategyFactory} from './passport';
2021

2122
export class AuthStrategyProvider implements Provider<Strategy | undefined> {
2223
constructor(
@@ -32,6 +33,8 @@ export class AuthStrategyProvider implements Provider<Strategy | undefined> {
3233
private readonly getGoogleAuthVerifier: GoogleAuthStrategyFactory,
3334
@inject(Strategies.Passport.AZURE_AD_STRATEGY_FACTORY)
3435
private readonly getAzureADAuthVerifier: AzureADAuthStrategyFactory,
36+
@inject(Strategies.Passport.KEYCLOAK_STRATEGY_FACTORY)
37+
private readonly getKeycloakVerifier: KeycloakStrategyFactory,
3538
) {}
3639

3740
value(): ValueOrPromise<Strategy | undefined> {
@@ -67,6 +70,8 @@ export class AuthStrategyProvider implements Provider<Strategy | undefined> {
6770
| AzureADAuthStrategy.IOIDCStrategyOptionWithRequest
6871
| AzureADAuthStrategy.IOIDCStrategyOptionWithoutRequest,
6972
);
73+
} else if (name === STRATEGY.KEYCLOAK) {
74+
return this.getKeycloakVerifier(this.metadata.options);
7075
} else {
7176
return Promise.reject(`The strategy ${name} is not available.`);
7277
}

src/strategy-name.enum.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ export const enum STRATEGY {
55
OAUTH2_RESOURCE_OWNER_GRANT = 'OAuth2 resource owner grant',
66
GOOGLE_OAUTH2 = 'Google Oauth 2.0',
77
AZURE_AD = 'Azure AD',
8+
KEYCLOAK = 'keycloak',
89
}

0 commit comments

Comments
 (0)