Feat(authentication): username password provider (#6052)
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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>,
|
||||
|
||||
Reference in New Issue
Block a user