-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(authentication-service): added keycloak signup provider (#89)
* feat(authentication-service): added keycloak signup provider added keycloak signup provider * style(authentication-service): sonar fix sonar fix
- Loading branch information
Showing
6 changed files
with
44 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './keys'; | ||
export * from './types'; | ||
export * from './google-oauth2-signup.provider'; | ||
export * from './keycloak-signup.provider'; |
14 changes: 14 additions & 0 deletions
14
services/authentication-service/src/providers/keycloak-signup.provider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import {Provider} from '@loopback/context'; | ||
import {HttpErrors} from '@loopback/rest'; | ||
import {KeyCloakSignUpFn} from './types'; | ||
import {AuthErrorKeys} from 'loopback4-authentication/index'; | ||
|
||
export class KeyCloakSignupProvider implements Provider<KeyCloakSignUpFn> { | ||
constructor() {} | ||
|
||
value(): KeyCloakSignUpFn { | ||
return async profile => { | ||
throw new HttpErrors.Unauthorized(AuthErrorKeys.InvalidCredentials); | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
import {BindingKey} from '@loopback/core'; | ||
import {GoogleSignUpFn} from './types'; | ||
import {GoogleSignUpFn, KeyCloakSignUpFn} from './types'; | ||
|
||
export namespace SignUpBindings { | ||
export const GOOGLE_SIGN_UP_PROVIDER = BindingKey.create<GoogleSignUpFn>( | ||
'sf.google.signup.provider', | ||
); | ||
} | ||
|
||
export namespace KeyCloakSignUpBindings { | ||
export const KEYCLOAK_SIGN_UP_PROVIDER = BindingKey.create<KeyCloakSignUpFn>( | ||
'sf.keycloak.signup.provider', | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
import * as GoogleStrategy from 'passport-google-oauth20'; | ||
import {User, UserRelations} from '../models'; | ||
import { KeycloakProfile } from 'loopback4-authentication'; | ||
|
||
export interface GoogleSignUpFn { | ||
(profile: GoogleStrategy.Profile): Promise<(User & UserRelations) | null>; | ||
} | ||
|
||
export interface KeyCloakSignUpFn { | ||
(profile: KeycloakProfile): Promise<(User & UserRelations) | null>; | ||
} |