Feat(authentication): username password provider (#6052)

This commit is contained in:
Philip Korsholm
2024-01-23 09:04:22 +00:00
committed by GitHub
parent 9d7ed9dbaf
commit 24bb26b81a
20 changed files with 424 additions and 44 deletions
@@ -4,6 +4,7 @@ import { AuthProviderDTO } from "./auth-provider"
export type AuthUserDTO = {
id: string
provider_id: string
entity_id: string
provider: AuthProviderDTO
provider_metadata?: Record<string, unknown>
user_metadata: Record<string, unknown>
@@ -12,6 +13,7 @@ export type AuthUserDTO = {
export type CreateAuthUserDTO = {
provider_id: string
entity_id: string
provider_metadata?: Record<string, unknown>
user_metadata?: Record<string, unknown>
app_metadata?: Record<string, unknown>
+17 -1
View File
@@ -1,8 +1,24 @@
import { AuthUserDTO } from "./common"
export abstract class AbstractAuthenticationModuleProvider {
public static PROVIDER: string
public static DISPLAY_NAME: string
public get provider() {
return (this.constructor as Function & { PROVIDER: string}).PROVIDER
}
public get displayName() {
return (this.constructor as Function & { DISPLAY_NAME: string}).DISPLAY_NAME
}
abstract authenticate(
data: Record<string, unknown>
): Promise<Record<string, unknown>>
): Promise<AuthenticationResponse>
}
export type AuthenticationResponse = {
success: boolean
authUser?: AuthUserDTO
error?: string
}
@@ -11,8 +11,14 @@ import {
} from "./common"
import { FindConfig } from "../common"
import { Context } from "../shared-context"
import { AuthenticationResponse } from "./provider"
export interface IAuthenticationModuleService extends IModuleService {
authenticate(
provider: string,
providerData: Record<string, unknown>
): Promise<AuthenticationResponse>
retrieveAuthProvider(
provider: string,
config?: FindConfig<AuthProviderDTO>,