-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.ts
84 lines (73 loc) · 1.8 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import type { AdminForthResource, IAdminForth, IHttpServer } from 'adminforth';
/**
* Configuration for an OAuth2 provider adapter
*/
export interface OAuth2ProviderAdapter {
/**
* Unique identifier for this OAuth provider
*/
providerId: string;
/**
* Display name of the provider shown in the UI
*/
providerName: string;
/**
* URL to provider's logo image to show in login button
*/
providerLogo?: string;
/**
* Validate adapter configuration
* Throws error if configuration is invalid
*/
validate(): void;
/**
* Get OAuth2 authorization URL that user will be redirected to
*/
getAuthorizationUrl(): string;
/**
* Exchange authorization code for access token and user info
*/
exchangeCodeForToken(code: string): Promise<{
error?: string;
userInfo?: {
email: string;
name?: string;
picture?: string;
[key: string]: any;
};
}>;
}
/**
* Plugin options for SSO authentication
*/
export interface PluginOptions {
/**
* OAuth2 provider adapter implementation
*/
provider: OAuth2ProviderAdapter;
/**
* Optional callback URL override
* If not provided, will use default AdminForth callback URL
*/
callbackUrl?: string;
/**
* Optional function to transform user info from provider
* into AdminForth user record before saving
*/
transformUserInfo?: (userInfo: any) => Promise<Record<string, any>>;
/**
* Optional function to validate if user is allowed to login
* For example to check if email domain is allowed
*/
validateUser?: (userInfo: any) => Promise<{
allowed: boolean;
error?: string;
}>;
}
export interface HttpExtra {
headers: Record<string, string>;
cookies: Record<string, string>;
requestUrl: string;
query: Record<string, any>;
body: Record<string, any>;
}