feat(auth): add authentication endpoints (#6265)
**What** - Add authentication endpoints: - `/auth/[scope]/[provider]` - `/auth/[scope]/[provider]/callback` - update authenticate-middleware handler - Add scope field to user - Add unique constraint on scope and entity_id note: there's still some remaining work related to jwt auth to be handled, this is mainly focussed on session auth with endpoints Co-authored-by: Sebastian Rindom <7554214+srindom@users.noreply.github.com>
This commit is contained in:
co-authored by
Sebastian Rindom
parent
061c449179
commit
9fda6a6824
@@ -3,7 +3,7 @@ import { BaseFilterable } from "../../dal"
|
||||
export type AuthProviderDTO = {
|
||||
provider: string
|
||||
name: string
|
||||
domain: ProviderDomain
|
||||
scope?: string
|
||||
is_active: boolean
|
||||
config: Record<string, unknown> | null
|
||||
}
|
||||
@@ -11,29 +11,22 @@ export type AuthProviderDTO = {
|
||||
export type CreateAuthProviderDTO = {
|
||||
provider: string
|
||||
name: string
|
||||
domain?: ProviderDomain
|
||||
scope?: string
|
||||
is_active?: boolean
|
||||
config?: Record<string, unknown>
|
||||
config?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export type UpdateAuthProviderDTO = {
|
||||
provider: string
|
||||
name?: string
|
||||
domain?: ProviderDomain
|
||||
is_active?: boolean
|
||||
config?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export enum ProviderDomain {
|
||||
ALL = "all",
|
||||
STORE = "store",
|
||||
ADMIN = "admin",
|
||||
}
|
||||
|
||||
export interface FilterableAuthProviderProps
|
||||
extends BaseFilterable<FilterableAuthProviderProps> {
|
||||
provider?: string[]
|
||||
is_active?: boolean
|
||||
domain?: ProviderDomain[]
|
||||
scope?: string[]
|
||||
name?: string[]
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { BaseFilterable } from "../../dal"
|
||||
import { AuthProviderDTO } from "./auth-provider"
|
||||
import { BaseFilterable } from "../../dal"
|
||||
|
||||
export type AuthUserDTO = {
|
||||
id: string
|
||||
provider_id: string
|
||||
entity_id: string
|
||||
scope: string
|
||||
provider: AuthProviderDTO
|
||||
provider_metadata?: Record<string, unknown>
|
||||
user_metadata: Record<string, unknown>
|
||||
@@ -12,8 +13,9 @@ export type AuthUserDTO = {
|
||||
}
|
||||
|
||||
export type CreateAuthUserDTO = {
|
||||
provider_id: string
|
||||
provider: string
|
||||
entity_id: string
|
||||
scope: string
|
||||
provider_metadata?: Record<string, unknown>
|
||||
user_metadata?: Record<string, unknown>
|
||||
app_metadata?: Record<string, unknown>
|
||||
|
||||
@@ -10,13 +10,13 @@ export type AuthModuleProviderConfig = {
|
||||
scopes: Record<string, AuthProviderScope>
|
||||
}
|
||||
|
||||
export type AuthProviderScope = { domain?: string } & Record<string, string>
|
||||
export type AuthProviderScope = Record<string, unknown>
|
||||
|
||||
export type AuthenticationInput = {
|
||||
connection: { encrypted: boolean }
|
||||
url: string
|
||||
headers: Record<string, string>
|
||||
query: Record<string, string>
|
||||
body: Record<string, string>
|
||||
scope: string
|
||||
authScope: string
|
||||
protocol: string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user