@absolutejs/auth 0.26.0-beta.2 → 0.26.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/audit/config.d.ts +2 -1
- package/dist/audit/types.d.ts +1 -1
- package/dist/authorization/config.d.ts +19 -0
- package/dist/authorization/protectPermission.d.ts +52 -0
- package/dist/compliance/cipher.d.ts +5 -0
- package/dist/compliance/config.d.ts +18 -0
- package/dist/compliance/redaction.d.ts +8 -0
- package/dist/compliance/routes.d.ts +89 -0
- package/dist/htmx/index.js +494 -98
- package/dist/htmx/index.js.map +3 -3
- package/dist/index.d.ts +7578 -430
- package/dist/index.js +4601 -1490
- package/dist/index.js.map +50 -13
- package/dist/organizations/config.d.ts +46 -0
- package/dist/organizations/inMemoryOrganizationStore.d.ts +2 -0
- package/dist/organizations/operations.d.ts +32 -0
- package/dist/organizations/postgresOrganizationStore.d.ts +412 -0
- package/dist/organizations/routes.d.ts +299 -0
- package/dist/organizations/types.d.ts +44 -0
- package/dist/passwordless/config.d.ts +42 -0
- package/dist/passwordless/inMemoryPasswordlessTokenStore.d.ts +2 -0
- package/dist/passwordless/postgresPasswordlessTokenStore.d.ts +66 -0
- package/dist/passwordless/routes.d.ts +163 -0
- package/dist/passwordless/types.d.ts +9 -0
- package/dist/providers/clients.d.ts +3 -3
- package/dist/roles/config.d.ts +27 -0
- package/dist/roles/inMemoryRoleStore.d.ts +2 -0
- package/dist/roles/operations.d.ts +8 -0
- package/dist/roles/postgresRoleStore.d.ts +102 -0
- package/dist/roles/resolver.d.ts +17 -0
- package/dist/roles/routes.d.ts +106 -0
- package/dist/roles/types.d.ts +14 -0
- package/dist/routes/authorize.d.ts +2 -2
- package/dist/routes/protectRoute.d.ts +2 -2
- package/dist/scim/config.d.ts +55 -0
- package/dist/scim/inMemoryScimTokenStore.d.ts +2 -0
- package/dist/scim/postgresScimTokenStore.d.ts +102 -0
- package/dist/scim/routes.d.ts +296 -0
- package/dist/scim/serialize.d.ts +45 -0
- package/dist/scim/types.d.ts +52 -0
- package/dist/session/promote.d.ts +9 -2
- package/dist/sso/config.d.ts +104 -0
- package/dist/sso/discoveryRoute.d.ts +63 -0
- package/dist/sso/inMemorySsoConnectionStore.d.ts +2 -0
- package/dist/sso/oidcRoutes.d.ts +97 -0
- package/dist/sso/postgresSsoConnectionStore.d.ts +139 -0
- package/dist/sso/samlRoutes.d.ts +176 -0
- package/dist/sso/types.d.ts +39 -0
- package/dist/typebox.d.ts +1 -1
- package/dist/types.d.ts +59 -0
- package/dist/webauthn/adapter.d.ts +59 -0
- package/dist/webauthn/config.d.ts +35 -0
- package/dist/webauthn/inMemoryWebAuthnCredentialStore.d.ts +2 -0
- package/dist/webauthn/postgresWebAuthnCredentialStore.d.ts +172 -0
- package/dist/webauthn/routes.d.ts +155 -0
- package/dist/webauthn/types.d.ts +17 -0
- package/dist/webhooks/config.d.ts +21 -0
- package/dist/webhooks/dispatcher.d.ts +3 -0
- package/dist/webhooks/sign.d.ts +11 -0
- package/dist/webhooks/types.d.ts +11 -0
- package/package.json +2 -2
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { Elysia } from 'elysia';
|
|
2
|
+
import { type ScimConfig } from './config';
|
|
3
|
+
export declare const scimRoutes: ({ getScimGroup, getScimUser, listScimGroups, listScimUsers, onScimGroupCreate, onScimGroupDelete, onScimGroupReplace, onScimUserCreate, onScimUserDeactivate, onScimUserReplace, scimRoute, scimTokenStore }: ScimConfig) => Elysia<"", {
|
|
4
|
+
decorator: {};
|
|
5
|
+
store: {};
|
|
6
|
+
derive: {};
|
|
7
|
+
resolve: {};
|
|
8
|
+
}, {
|
|
9
|
+
typebox: {};
|
|
10
|
+
error: {};
|
|
11
|
+
}, {
|
|
12
|
+
schema: {};
|
|
13
|
+
standaloneSchema: {};
|
|
14
|
+
macro: {};
|
|
15
|
+
macroFn: {};
|
|
16
|
+
parser: {};
|
|
17
|
+
response: {};
|
|
18
|
+
}, {
|
|
19
|
+
[x: string]: {
|
|
20
|
+
get: {
|
|
21
|
+
body: unknown;
|
|
22
|
+
params: {};
|
|
23
|
+
query: unknown;
|
|
24
|
+
headers: unknown;
|
|
25
|
+
response: {
|
|
26
|
+
200: Response;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
} & {
|
|
31
|
+
[x: string]: {
|
|
32
|
+
post: {
|
|
33
|
+
body: unknown;
|
|
34
|
+
params: {};
|
|
35
|
+
query: unknown;
|
|
36
|
+
headers: unknown;
|
|
37
|
+
response: {
|
|
38
|
+
200: Response;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
} & {
|
|
43
|
+
[x: string]: {
|
|
44
|
+
get: {
|
|
45
|
+
body: unknown;
|
|
46
|
+
params: {};
|
|
47
|
+
query: {
|
|
48
|
+
filter?: string | undefined;
|
|
49
|
+
};
|
|
50
|
+
headers: unknown;
|
|
51
|
+
response: {
|
|
52
|
+
200: Response;
|
|
53
|
+
422: {
|
|
54
|
+
type: "validation";
|
|
55
|
+
on: string;
|
|
56
|
+
summary?: string;
|
|
57
|
+
message?: string;
|
|
58
|
+
found?: unknown;
|
|
59
|
+
property?: string;
|
|
60
|
+
expected?: string;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
} & {
|
|
66
|
+
[x: string]: {
|
|
67
|
+
get: {
|
|
68
|
+
body: unknown;
|
|
69
|
+
params: {
|
|
70
|
+
id: string;
|
|
71
|
+
};
|
|
72
|
+
query: unknown;
|
|
73
|
+
headers: unknown;
|
|
74
|
+
response: {
|
|
75
|
+
200: Response;
|
|
76
|
+
422: {
|
|
77
|
+
type: "validation";
|
|
78
|
+
on: string;
|
|
79
|
+
summary?: string;
|
|
80
|
+
message?: string;
|
|
81
|
+
found?: unknown;
|
|
82
|
+
property?: string;
|
|
83
|
+
expected?: string;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
} & {
|
|
89
|
+
[x: string]: {
|
|
90
|
+
put: {
|
|
91
|
+
body: unknown;
|
|
92
|
+
params: {
|
|
93
|
+
id: string;
|
|
94
|
+
};
|
|
95
|
+
query: unknown;
|
|
96
|
+
headers: unknown;
|
|
97
|
+
response: {
|
|
98
|
+
200: Response;
|
|
99
|
+
422: {
|
|
100
|
+
type: "validation";
|
|
101
|
+
on: string;
|
|
102
|
+
summary?: string;
|
|
103
|
+
message?: string;
|
|
104
|
+
found?: unknown;
|
|
105
|
+
property?: string;
|
|
106
|
+
expected?: string;
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
} & {
|
|
112
|
+
[x: string]: {
|
|
113
|
+
patch: {
|
|
114
|
+
body: unknown;
|
|
115
|
+
params: {
|
|
116
|
+
id: string;
|
|
117
|
+
};
|
|
118
|
+
query: unknown;
|
|
119
|
+
headers: unknown;
|
|
120
|
+
response: {
|
|
121
|
+
200: Response;
|
|
122
|
+
422: {
|
|
123
|
+
type: "validation";
|
|
124
|
+
on: string;
|
|
125
|
+
summary?: string;
|
|
126
|
+
message?: string;
|
|
127
|
+
found?: unknown;
|
|
128
|
+
property?: string;
|
|
129
|
+
expected?: string;
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
} & {
|
|
135
|
+
[x: string]: {
|
|
136
|
+
delete: {
|
|
137
|
+
body: unknown;
|
|
138
|
+
params: {
|
|
139
|
+
id: string;
|
|
140
|
+
};
|
|
141
|
+
query: unknown;
|
|
142
|
+
headers: unknown;
|
|
143
|
+
response: {
|
|
144
|
+
200: Response;
|
|
145
|
+
422: {
|
|
146
|
+
type: "validation";
|
|
147
|
+
on: string;
|
|
148
|
+
summary?: string;
|
|
149
|
+
message?: string;
|
|
150
|
+
found?: unknown;
|
|
151
|
+
property?: string;
|
|
152
|
+
expected?: string;
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
} & {
|
|
158
|
+
[x: string]: {
|
|
159
|
+
post: {
|
|
160
|
+
body: unknown;
|
|
161
|
+
params: {};
|
|
162
|
+
query: unknown;
|
|
163
|
+
headers: unknown;
|
|
164
|
+
response: {
|
|
165
|
+
200: Response;
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
} & {
|
|
170
|
+
[x: string]: {
|
|
171
|
+
get: {
|
|
172
|
+
body: unknown;
|
|
173
|
+
params: {};
|
|
174
|
+
query: {
|
|
175
|
+
filter?: string | undefined;
|
|
176
|
+
};
|
|
177
|
+
headers: unknown;
|
|
178
|
+
response: {
|
|
179
|
+
200: Response;
|
|
180
|
+
422: {
|
|
181
|
+
type: "validation";
|
|
182
|
+
on: string;
|
|
183
|
+
summary?: string;
|
|
184
|
+
message?: string;
|
|
185
|
+
found?: unknown;
|
|
186
|
+
property?: string;
|
|
187
|
+
expected?: string;
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
} & {
|
|
193
|
+
[x: string]: {
|
|
194
|
+
get: {
|
|
195
|
+
body: unknown;
|
|
196
|
+
params: {
|
|
197
|
+
id: string;
|
|
198
|
+
};
|
|
199
|
+
query: unknown;
|
|
200
|
+
headers: unknown;
|
|
201
|
+
response: {
|
|
202
|
+
200: Response;
|
|
203
|
+
422: {
|
|
204
|
+
type: "validation";
|
|
205
|
+
on: string;
|
|
206
|
+
summary?: string;
|
|
207
|
+
message?: string;
|
|
208
|
+
found?: unknown;
|
|
209
|
+
property?: string;
|
|
210
|
+
expected?: string;
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
} & {
|
|
216
|
+
[x: string]: {
|
|
217
|
+
put: {
|
|
218
|
+
body: unknown;
|
|
219
|
+
params: {
|
|
220
|
+
id: string;
|
|
221
|
+
};
|
|
222
|
+
query: unknown;
|
|
223
|
+
headers: unknown;
|
|
224
|
+
response: {
|
|
225
|
+
200: Response;
|
|
226
|
+
422: {
|
|
227
|
+
type: "validation";
|
|
228
|
+
on: string;
|
|
229
|
+
summary?: string;
|
|
230
|
+
message?: string;
|
|
231
|
+
found?: unknown;
|
|
232
|
+
property?: string;
|
|
233
|
+
expected?: string;
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
};
|
|
237
|
+
};
|
|
238
|
+
} & {
|
|
239
|
+
[x: string]: {
|
|
240
|
+
patch: {
|
|
241
|
+
body: unknown;
|
|
242
|
+
params: {
|
|
243
|
+
id: string;
|
|
244
|
+
};
|
|
245
|
+
query: unknown;
|
|
246
|
+
headers: unknown;
|
|
247
|
+
response: {
|
|
248
|
+
200: Response;
|
|
249
|
+
422: {
|
|
250
|
+
type: "validation";
|
|
251
|
+
on: string;
|
|
252
|
+
summary?: string;
|
|
253
|
+
message?: string;
|
|
254
|
+
found?: unknown;
|
|
255
|
+
property?: string;
|
|
256
|
+
expected?: string;
|
|
257
|
+
};
|
|
258
|
+
};
|
|
259
|
+
};
|
|
260
|
+
};
|
|
261
|
+
} & {
|
|
262
|
+
[x: string]: {
|
|
263
|
+
delete: {
|
|
264
|
+
body: unknown;
|
|
265
|
+
params: {
|
|
266
|
+
id: string;
|
|
267
|
+
};
|
|
268
|
+
query: unknown;
|
|
269
|
+
headers: unknown;
|
|
270
|
+
response: {
|
|
271
|
+
200: Response;
|
|
272
|
+
422: {
|
|
273
|
+
type: "validation";
|
|
274
|
+
on: string;
|
|
275
|
+
summary?: string;
|
|
276
|
+
message?: string;
|
|
277
|
+
found?: unknown;
|
|
278
|
+
property?: string;
|
|
279
|
+
expected?: string;
|
|
280
|
+
};
|
|
281
|
+
};
|
|
282
|
+
};
|
|
283
|
+
};
|
|
284
|
+
}, {
|
|
285
|
+
derive: {};
|
|
286
|
+
resolve: {};
|
|
287
|
+
schema: {};
|
|
288
|
+
standaloneSchema: {};
|
|
289
|
+
response: {};
|
|
290
|
+
}, {
|
|
291
|
+
derive: {};
|
|
292
|
+
resolve: {};
|
|
293
|
+
schema: {};
|
|
294
|
+
standaloneSchema: {};
|
|
295
|
+
response: {};
|
|
296
|
+
}>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { ScimFilter, ScimGroup, ScimGroupInput, ScimUser, ScimUserInput } from './types';
|
|
2
|
+
export declare const toUserResource: (user: ScimUser, location: string) => Record<string, unknown>;
|
|
3
|
+
export declare const parseUserInput: (body: unknown) => ScimUserInput | undefined;
|
|
4
|
+
export declare const applyPatch: (user: ScimUser, body: unknown) => ScimUserInput;
|
|
5
|
+
export declare const listResponse: (resources: Record<string, unknown>[]) => {
|
|
6
|
+
itemsPerPage: number;
|
|
7
|
+
Resources: Record<string, unknown>[];
|
|
8
|
+
schemas: string[];
|
|
9
|
+
startIndex: number;
|
|
10
|
+
totalResults: number;
|
|
11
|
+
};
|
|
12
|
+
export declare const parseFilter: (filter: string | undefined) => ScimFilter | undefined;
|
|
13
|
+
export declare const scimError: (httpStatus: number, detail: string, scimType?: string) => Response;
|
|
14
|
+
export declare const scimJson: (resource: unknown, httpStatus: number) => Response;
|
|
15
|
+
export declare const serviceProviderConfig: (location: string) => {
|
|
16
|
+
bulk: {
|
|
17
|
+
maxOperations: number;
|
|
18
|
+
maxPayloadSize: number;
|
|
19
|
+
supported: boolean;
|
|
20
|
+
};
|
|
21
|
+
changePassword: {
|
|
22
|
+
supported: boolean;
|
|
23
|
+
};
|
|
24
|
+
etag: {
|
|
25
|
+
supported: boolean;
|
|
26
|
+
};
|
|
27
|
+
filter: {
|
|
28
|
+
maxResults: number;
|
|
29
|
+
supported: boolean;
|
|
30
|
+
};
|
|
31
|
+
meta: {
|
|
32
|
+
location: string;
|
|
33
|
+
resourceType: string;
|
|
34
|
+
};
|
|
35
|
+
patch: {
|
|
36
|
+
supported: boolean;
|
|
37
|
+
};
|
|
38
|
+
schemas: string[];
|
|
39
|
+
sort: {
|
|
40
|
+
supported: boolean;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export declare const applyGroupPatch: (group: ScimGroup, body: unknown) => ScimGroupInput;
|
|
44
|
+
export declare const parseGroupInput: (body: unknown) => ScimGroupInput | undefined;
|
|
45
|
+
export declare const toGroupResource: (group: ScimGroup, location: string) => Record<string, unknown>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { OrganizationId } from '../tenancy';
|
|
2
|
+
export type ScimToken = {
|
|
3
|
+
createdAt: number;
|
|
4
|
+
hashedToken: string;
|
|
5
|
+
lastUsedAt?: number;
|
|
6
|
+
organizationId: OrganizationId;
|
|
7
|
+
tokenId: string;
|
|
8
|
+
};
|
|
9
|
+
export type ScimTokenStore = {
|
|
10
|
+
deleteToken: (tokenId: string) => Promise<void>;
|
|
11
|
+
findByHashedToken: (hashedToken: string) => Promise<ScimToken | undefined>;
|
|
12
|
+
listTokens: (organizationId: OrganizationId) => Promise<ScimToken[]>;
|
|
13
|
+
saveToken: (token: ScimToken) => Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
export type ScimUser = {
|
|
16
|
+
active: boolean;
|
|
17
|
+
displayName?: string;
|
|
18
|
+
email?: string;
|
|
19
|
+
externalId?: string;
|
|
20
|
+
familyName?: string;
|
|
21
|
+
givenName?: string;
|
|
22
|
+
id: string;
|
|
23
|
+
userName: string;
|
|
24
|
+
};
|
|
25
|
+
export type ScimUserInput = {
|
|
26
|
+
active: boolean;
|
|
27
|
+
displayName?: string;
|
|
28
|
+
email?: string;
|
|
29
|
+
externalId?: string;
|
|
30
|
+
familyName?: string;
|
|
31
|
+
givenName?: string;
|
|
32
|
+
userName: string;
|
|
33
|
+
};
|
|
34
|
+
export type ScimGroupMember = {
|
|
35
|
+
display?: string;
|
|
36
|
+
value: string;
|
|
37
|
+
};
|
|
38
|
+
export type ScimGroup = {
|
|
39
|
+
displayName: string;
|
|
40
|
+
externalId?: string;
|
|
41
|
+
id: string;
|
|
42
|
+
members: ScimGroupMember[];
|
|
43
|
+
};
|
|
44
|
+
export type ScimGroupInput = {
|
|
45
|
+
displayName: string;
|
|
46
|
+
externalId?: string;
|
|
47
|
+
members: ScimGroupMember[];
|
|
48
|
+
};
|
|
49
|
+
export type ScimFilter = {
|
|
50
|
+
attribute: string;
|
|
51
|
+
value: string;
|
|
52
|
+
};
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import type { Cookie } from 'elysia';
|
|
2
|
-
import type { SessionRecord, UserSessionId } from '../types';
|
|
2
|
+
import type { SessionData, SessionRecord, UserSessionId } from '../types';
|
|
3
3
|
import type { AuthSessionStore } from './types';
|
|
4
|
+
type ClearSessionProps<UserType> = {
|
|
5
|
+
authSessionStore?: AuthSessionStore<UserType>;
|
|
6
|
+
cookie: Cookie<UserSessionId | undefined>;
|
|
7
|
+
inMemorySession: SessionRecord<UserType>;
|
|
8
|
+
};
|
|
9
|
+
export declare const clearSession: <UserType>({ authSessionStore, cookie, inMemorySession }: ClearSessionProps<UserType>) => Promise<void>;
|
|
4
10
|
export declare const persistWhen: (shouldPersist: boolean, persist: () => Promise<void>) => Promise<void>;
|
|
5
11
|
type PromoteToSessionProps<UserType> = {
|
|
6
12
|
authSessionStore?: AuthSessionStore<UserType>;
|
|
7
13
|
cookie: Cookie<UserSessionId | undefined>;
|
|
8
14
|
inMemorySession: SessionRecord<UserType>;
|
|
15
|
+
samlLogout?: SessionData<UserType>['samlLogout'];
|
|
9
16
|
sessionDurationMs: number;
|
|
10
17
|
user: UserType;
|
|
11
18
|
};
|
|
12
|
-
export declare const promoteToSession: <UserType>({ authSessionStore, cookie, inMemorySession, sessionDurationMs, user }: PromoteToSessionProps<UserType>) => Promise<`${string}-${string}-${string}-${string}-${string}`>;
|
|
19
|
+
export declare const promoteToSession: <UserType>({ authSessionStore, cookie, inMemorySession, samlLogout, sessionDurationMs, user }: PromoteToSessionProps<UserType>) => Promise<`${string}-${string}-${string}-${string}-${string}`>;
|
|
13
20
|
export {};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { OAuth2TokenResponse, OIDCIdTokenClaims } from 'citra';
|
|
2
|
+
import type { OrganizationId } from '../tenancy';
|
|
3
|
+
import type { RouteString, UserSessionId } from '../types';
|
|
4
|
+
import type { OidcConnection, SamlConnection, SSOConnectionStore } from './types';
|
|
5
|
+
export declare const DEFAULT_SSO_ROUTE = "/sso";
|
|
6
|
+
export declare const DEFAULT_SSO_SESSION_TTL_MS: number;
|
|
7
|
+
export type SamlProfile = {
|
|
8
|
+
attributes: Record<string, unknown>;
|
|
9
|
+
email?: string;
|
|
10
|
+
nameId: string;
|
|
11
|
+
sessionIndex?: string;
|
|
12
|
+
};
|
|
13
|
+
type SamlAuthorizeRequest = {
|
|
14
|
+
acsUrl: string;
|
|
15
|
+
connection: SamlConnection;
|
|
16
|
+
relayState?: string;
|
|
17
|
+
};
|
|
18
|
+
type SamlAssertionRequest = {
|
|
19
|
+
acsUrl: string;
|
|
20
|
+
connection: SamlConnection;
|
|
21
|
+
relayState?: string;
|
|
22
|
+
samlResponse: string;
|
|
23
|
+
};
|
|
24
|
+
type SamlMetadataRequest = {
|
|
25
|
+
acsUrl: string;
|
|
26
|
+
connection: SamlConnection;
|
|
27
|
+
};
|
|
28
|
+
type SamlLogoutRequest = {
|
|
29
|
+
connection: SamlConnection;
|
|
30
|
+
nameId: string;
|
|
31
|
+
relayState?: string;
|
|
32
|
+
sessionIndex?: string;
|
|
33
|
+
sloUrl: string;
|
|
34
|
+
};
|
|
35
|
+
type SamlLogoutResponseRequest = {
|
|
36
|
+
connection: SamlConnection;
|
|
37
|
+
relayState?: string;
|
|
38
|
+
samlResponse: string;
|
|
39
|
+
sloUrl: string;
|
|
40
|
+
};
|
|
41
|
+
type SamlIdpLogoutRequest = {
|
|
42
|
+
connection: SamlConnection;
|
|
43
|
+
relayState?: string;
|
|
44
|
+
samlRequest: string;
|
|
45
|
+
sloUrl: string;
|
|
46
|
+
};
|
|
47
|
+
type SamlLogoutResponseAck = {
|
|
48
|
+
connection: SamlConnection;
|
|
49
|
+
inResponseTo?: string;
|
|
50
|
+
nameId?: string;
|
|
51
|
+
relayState?: string;
|
|
52
|
+
sloUrl: string;
|
|
53
|
+
};
|
|
54
|
+
export type SamlLogoutInfo = {
|
|
55
|
+
nameId?: string;
|
|
56
|
+
relayState?: string;
|
|
57
|
+
requestId?: string;
|
|
58
|
+
sessionIndex?: string;
|
|
59
|
+
};
|
|
60
|
+
export type SamlAdapter = {
|
|
61
|
+
createAuthorizationUrl: (request: SamlAuthorizeRequest) => Promise<string> | string;
|
|
62
|
+
createLogoutRequestUrl?: (request: SamlLogoutRequest) => Promise<string> | string;
|
|
63
|
+
createLogoutResponseUrl?: (request: SamlLogoutResponseAck) => Promise<string> | string;
|
|
64
|
+
getServiceProviderMetadata: (request: SamlMetadataRequest) => Promise<string> | string;
|
|
65
|
+
validateAssertion: (request: SamlAssertionRequest) => Promise<SamlProfile>;
|
|
66
|
+
validateLogoutRequest?: (request: SamlIdpLogoutRequest) => Promise<SamlLogoutInfo> | SamlLogoutInfo;
|
|
67
|
+
validateLogoutResponse?: (request: SamlLogoutResponseRequest) => Promise<void> | void;
|
|
68
|
+
};
|
|
69
|
+
type SsoIdentityBase = {
|
|
70
|
+
email?: string;
|
|
71
|
+
organizationId: OrganizationId;
|
|
72
|
+
sub: string;
|
|
73
|
+
};
|
|
74
|
+
export type OidcSsoIdentity = SsoIdentityBase & {
|
|
75
|
+
claims: OIDCIdTokenClaims;
|
|
76
|
+
connection: OidcConnection;
|
|
77
|
+
protocol: 'oidc';
|
|
78
|
+
tokenResponse: OAuth2TokenResponse;
|
|
79
|
+
};
|
|
80
|
+
export type SamlSsoIdentity = SsoIdentityBase & {
|
|
81
|
+
attributes: Record<string, unknown>;
|
|
82
|
+
connection: SamlConnection;
|
|
83
|
+
protocol: 'saml';
|
|
84
|
+
sessionIndex?: string;
|
|
85
|
+
};
|
|
86
|
+
export type SsoIdentity = OidcSsoIdentity | SamlSsoIdentity;
|
|
87
|
+
export type SSOConfig<UserType> = {
|
|
88
|
+
getOrganizationByEmailDomain?: (domain: string) => OrganizationId | undefined | Promise<OrganizationId | undefined>;
|
|
89
|
+
getSsoUser: (identity: SsoIdentity) => Promise<UserType> | UserType;
|
|
90
|
+
onSsoCallbackError?: (context: {
|
|
91
|
+
error: unknown;
|
|
92
|
+
organizationId: string;
|
|
93
|
+
}) => void | Promise<void>;
|
|
94
|
+
onSsoCallbackSuccess?: (context: {
|
|
95
|
+
identity: SsoIdentity;
|
|
96
|
+
user: UserType;
|
|
97
|
+
userSessionId: UserSessionId;
|
|
98
|
+
}) => void | Promise<void>;
|
|
99
|
+
samlAdapter?: SamlAdapter;
|
|
100
|
+
sessionDurationMs?: number;
|
|
101
|
+
ssoConnectionStore: SSOConnectionStore;
|
|
102
|
+
ssoRoute?: RouteString;
|
|
103
|
+
};
|
|
104
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Elysia } from 'elysia';
|
|
2
|
+
import type { OrganizationId } from '../tenancy';
|
|
3
|
+
import type { RouteString } from '../types';
|
|
4
|
+
import type { SSOConnectionStore } from './types';
|
|
5
|
+
type SsoDiscoveryProps = {
|
|
6
|
+
getOrganizationByEmailDomain: (domain: string) => OrganizationId | undefined | Promise<OrganizationId | undefined>;
|
|
7
|
+
ssoConnectionStore: SSOConnectionStore;
|
|
8
|
+
ssoRoute?: RouteString;
|
|
9
|
+
};
|
|
10
|
+
export declare const ssoDiscoveryRoute: ({ getOrganizationByEmailDomain, ssoConnectionStore, ssoRoute }: SsoDiscoveryProps) => Elysia<"", {
|
|
11
|
+
decorator: {};
|
|
12
|
+
store: {};
|
|
13
|
+
derive: {};
|
|
14
|
+
resolve: {};
|
|
15
|
+
}, {
|
|
16
|
+
typebox: {};
|
|
17
|
+
error: {};
|
|
18
|
+
}, {
|
|
19
|
+
schema: {};
|
|
20
|
+
standaloneSchema: {};
|
|
21
|
+
macro: {};
|
|
22
|
+
macroFn: {};
|
|
23
|
+
parser: {};
|
|
24
|
+
response: {};
|
|
25
|
+
}, {
|
|
26
|
+
[x: string]: {
|
|
27
|
+
get: {
|
|
28
|
+
body: unknown;
|
|
29
|
+
params: {};
|
|
30
|
+
query: {
|
|
31
|
+
email?: string | undefined;
|
|
32
|
+
};
|
|
33
|
+
headers: unknown;
|
|
34
|
+
response: {
|
|
35
|
+
200: Response;
|
|
36
|
+
400: "An \"email\" query parameter is required" | "A valid email address is required";
|
|
37
|
+
404: "No SSO organization is configured for this email domain" | "No SSO connection is configured for this organization";
|
|
38
|
+
422: {
|
|
39
|
+
type: "validation";
|
|
40
|
+
on: string;
|
|
41
|
+
summary?: string;
|
|
42
|
+
message?: string;
|
|
43
|
+
found?: unknown;
|
|
44
|
+
property?: string;
|
|
45
|
+
expected?: string;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
}, {
|
|
51
|
+
derive: {};
|
|
52
|
+
resolve: {};
|
|
53
|
+
schema: {};
|
|
54
|
+
standaloneSchema: {};
|
|
55
|
+
response: {};
|
|
56
|
+
}, {
|
|
57
|
+
derive: {};
|
|
58
|
+
resolve: {};
|
|
59
|
+
schema: {};
|
|
60
|
+
standaloneSchema: {};
|
|
61
|
+
response: {};
|
|
62
|
+
}>;
|
|
63
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Elysia } from 'elysia';
|
|
2
|
+
import type { AuthSessionStore } from '../session/types';
|
|
3
|
+
import { type SSOConfig } from './config';
|
|
4
|
+
type OidcRoutesProps<UserType> = SSOConfig<UserType> & {
|
|
5
|
+
authSessionStore?: AuthSessionStore<UserType>;
|
|
6
|
+
};
|
|
7
|
+
export declare const oidcSsoRoutes: <UserType>({ authSessionStore, getSsoUser, onSsoCallbackError, onSsoCallbackSuccess, sessionDurationMs, ssoConnectionStore, ssoRoute }: OidcRoutesProps<UserType>) => Elysia<"", {
|
|
8
|
+
decorator: {};
|
|
9
|
+
store: {
|
|
10
|
+
session: import("..").SessionRecord<UserType>;
|
|
11
|
+
unregisteredSession: import("..").UnregisteredSessionRecord;
|
|
12
|
+
};
|
|
13
|
+
derive: {};
|
|
14
|
+
resolve: {};
|
|
15
|
+
}, {
|
|
16
|
+
typebox: {};
|
|
17
|
+
error: {};
|
|
18
|
+
}, {
|
|
19
|
+
schema: {};
|
|
20
|
+
standaloneSchema: {};
|
|
21
|
+
macro: {};
|
|
22
|
+
macroFn: {};
|
|
23
|
+
parser: {};
|
|
24
|
+
response: {};
|
|
25
|
+
}, {
|
|
26
|
+
[x: string]: {
|
|
27
|
+
get: {
|
|
28
|
+
body: unknown;
|
|
29
|
+
params: {
|
|
30
|
+
organizationId: string;
|
|
31
|
+
};
|
|
32
|
+
query: unknown;
|
|
33
|
+
headers: unknown;
|
|
34
|
+
response: {
|
|
35
|
+
200: Response;
|
|
36
|
+
404: "No OIDC connection is configured for this organization";
|
|
37
|
+
422: {
|
|
38
|
+
type: "validation";
|
|
39
|
+
on: string;
|
|
40
|
+
summary?: string;
|
|
41
|
+
message?: string;
|
|
42
|
+
found?: unknown;
|
|
43
|
+
property?: string;
|
|
44
|
+
expected?: string;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
} & {
|
|
50
|
+
[x: string]: {
|
|
51
|
+
get: {
|
|
52
|
+
body: unknown;
|
|
53
|
+
params: {
|
|
54
|
+
organizationId: string;
|
|
55
|
+
};
|
|
56
|
+
query: {
|
|
57
|
+
code?: string | undefined;
|
|
58
|
+
state?: string | undefined;
|
|
59
|
+
};
|
|
60
|
+
headers: unknown;
|
|
61
|
+
response: {
|
|
62
|
+
200: Response;
|
|
63
|
+
400: "SSO session cookies are missing" | "Invalid SSO callback request" | "SSO organization mismatch" | "OIDC token response is missing an id_token";
|
|
64
|
+
404: "No OIDC connection is configured for this organization";
|
|
65
|
+
422: {
|
|
66
|
+
type: "validation";
|
|
67
|
+
on: string;
|
|
68
|
+
summary?: string;
|
|
69
|
+
message?: string;
|
|
70
|
+
found?: unknown;
|
|
71
|
+
property?: string;
|
|
72
|
+
expected?: string;
|
|
73
|
+
};
|
|
74
|
+
500: "OIDC sign-in failed";
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
}, {
|
|
79
|
+
derive: {};
|
|
80
|
+
resolve: {};
|
|
81
|
+
schema: {};
|
|
82
|
+
standaloneSchema: {};
|
|
83
|
+
response: {};
|
|
84
|
+
}, {
|
|
85
|
+
derive: {};
|
|
86
|
+
resolve: {};
|
|
87
|
+
schema: {};
|
|
88
|
+
standaloneSchema: {};
|
|
89
|
+
response: {};
|
|
90
|
+
} & {
|
|
91
|
+
derive: {};
|
|
92
|
+
resolve: {};
|
|
93
|
+
schema: {};
|
|
94
|
+
standaloneSchema: {};
|
|
95
|
+
response: {};
|
|
96
|
+
}>;
|
|
97
|
+
export {};
|