@absolutejs/auth 0.30.0-beta.5 → 0.30.0
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/index.d.ts +3 -0
- package/dist/index.js +312 -46
- package/dist/index.js.map +8 -5
- package/dist/sso/config.d.ts +38 -0
- package/dist/sso/inMemorySamlServiceProviderStore.d.ts +2 -0
- package/dist/sso/postgresSamlServiceProviderStore.d.ts +119 -0
- package/dist/sso/samlIdpRoutes.d.ts +139 -0
- package/dist/sso/types.d.ts +14 -0
- package/package.json +1 -1
package/dist/sso/config.d.ts
CHANGED
|
@@ -57,6 +57,44 @@ export type SamlLogoutInfo = {
|
|
|
57
57
|
requestId?: string;
|
|
58
58
|
sessionIndex?: string;
|
|
59
59
|
};
|
|
60
|
+
export type SamlAuthnRequestInfo = {
|
|
61
|
+
acsUrl?: string;
|
|
62
|
+
forceAuthn?: boolean;
|
|
63
|
+
id: string;
|
|
64
|
+
issuer: string;
|
|
65
|
+
relayState?: string;
|
|
66
|
+
};
|
|
67
|
+
export type SamlIdpResponseRequest = {
|
|
68
|
+
acsUrl: string;
|
|
69
|
+
attributes?: Record<string, unknown>;
|
|
70
|
+
audience: string;
|
|
71
|
+
idpEntityId: string;
|
|
72
|
+
inResponseTo?: string;
|
|
73
|
+
nameId: string;
|
|
74
|
+
nameIdFormat?: string;
|
|
75
|
+
relayState?: string;
|
|
76
|
+
sessionIndex: string;
|
|
77
|
+
};
|
|
78
|
+
export type SamlIdpAdapter = {
|
|
79
|
+
buildAutoPostForm: (input: {
|
|
80
|
+
acsUrl: string;
|
|
81
|
+
relayState?: string;
|
|
82
|
+
samlResponse: string;
|
|
83
|
+
}) => string;
|
|
84
|
+
createSamlResponse: (request: SamlIdpResponseRequest) => Promise<string> | string;
|
|
85
|
+
getIdpMetadata: (input: {
|
|
86
|
+
entityId: string;
|
|
87
|
+
ssoUrl: string;
|
|
88
|
+
}) => Promise<string> | string;
|
|
89
|
+
parseAuthnRequest: (input: {
|
|
90
|
+
binding: 'POST' | 'Redirect';
|
|
91
|
+
samlRequest: string;
|
|
92
|
+
serviceProvider?: import('./types').SamlServiceProvider;
|
|
93
|
+
signature?: string;
|
|
94
|
+
signatureAlgorithm?: string;
|
|
95
|
+
signedQueryString?: string;
|
|
96
|
+
}) => Promise<SamlAuthnRequestInfo> | SamlAuthnRequestInfo;
|
|
97
|
+
};
|
|
60
98
|
export type SamlAdapter = {
|
|
61
99
|
createAuthorizationUrl: (request: SamlAuthorizeRequest) => Promise<string> | string;
|
|
62
100
|
createLogoutRequestUrl?: (request: SamlLogoutRequest) => Promise<string> | string;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { type AnyPgDatabase } from '../stores/postgres';
|
|
2
|
+
import type { SamlServiceProviderStore } from './types';
|
|
3
|
+
export declare const samlServiceProvidersTable: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
4
|
+
name: "auth_saml_service_providers";
|
|
5
|
+
schema: undefined;
|
|
6
|
+
columns: {
|
|
7
|
+
acs_url: import("drizzle-orm/pg-core").PgColumn<{
|
|
8
|
+
name: "acs_url";
|
|
9
|
+
tableName: "auth_saml_service_providers";
|
|
10
|
+
dataType: "string";
|
|
11
|
+
columnType: "PgVarchar";
|
|
12
|
+
data: string;
|
|
13
|
+
driverParam: string;
|
|
14
|
+
notNull: true;
|
|
15
|
+
hasDefault: false;
|
|
16
|
+
isPrimaryKey: false;
|
|
17
|
+
isAutoincrement: false;
|
|
18
|
+
hasRuntimeDefault: false;
|
|
19
|
+
enumValues: [string, ...string[]];
|
|
20
|
+
baseColumn: never;
|
|
21
|
+
identity: undefined;
|
|
22
|
+
generated: undefined;
|
|
23
|
+
}, {}, {
|
|
24
|
+
length: 2048;
|
|
25
|
+
}>;
|
|
26
|
+
created_at_ms: import("drizzle-orm/pg-core").PgColumn<{
|
|
27
|
+
name: "created_at_ms";
|
|
28
|
+
tableName: "auth_saml_service_providers";
|
|
29
|
+
dataType: "number";
|
|
30
|
+
columnType: "PgBigInt53";
|
|
31
|
+
data: number;
|
|
32
|
+
driverParam: string | number;
|
|
33
|
+
notNull: true;
|
|
34
|
+
hasDefault: false;
|
|
35
|
+
isPrimaryKey: false;
|
|
36
|
+
isAutoincrement: false;
|
|
37
|
+
hasRuntimeDefault: false;
|
|
38
|
+
enumValues: undefined;
|
|
39
|
+
baseColumn: never;
|
|
40
|
+
identity: undefined;
|
|
41
|
+
generated: undefined;
|
|
42
|
+
}, {}, {}>;
|
|
43
|
+
entity_id: import("drizzle-orm/pg-core").PgColumn<{
|
|
44
|
+
name: "entity_id";
|
|
45
|
+
tableName: "auth_saml_service_providers";
|
|
46
|
+
dataType: "string";
|
|
47
|
+
columnType: "PgVarchar";
|
|
48
|
+
data: string;
|
|
49
|
+
driverParam: string;
|
|
50
|
+
notNull: true;
|
|
51
|
+
hasDefault: false;
|
|
52
|
+
isPrimaryKey: true;
|
|
53
|
+
isAutoincrement: false;
|
|
54
|
+
hasRuntimeDefault: false;
|
|
55
|
+
enumValues: [string, ...string[]];
|
|
56
|
+
baseColumn: never;
|
|
57
|
+
identity: undefined;
|
|
58
|
+
generated: undefined;
|
|
59
|
+
}, {}, {
|
|
60
|
+
length: 2048;
|
|
61
|
+
}>;
|
|
62
|
+
name_id_format: import("drizzle-orm/pg-core").PgColumn<{
|
|
63
|
+
name: "name_id_format";
|
|
64
|
+
tableName: "auth_saml_service_providers";
|
|
65
|
+
dataType: "string";
|
|
66
|
+
columnType: "PgVarchar";
|
|
67
|
+
data: string;
|
|
68
|
+
driverParam: string;
|
|
69
|
+
notNull: false;
|
|
70
|
+
hasDefault: false;
|
|
71
|
+
isPrimaryKey: false;
|
|
72
|
+
isAutoincrement: false;
|
|
73
|
+
hasRuntimeDefault: false;
|
|
74
|
+
enumValues: [string, ...string[]];
|
|
75
|
+
baseColumn: never;
|
|
76
|
+
identity: undefined;
|
|
77
|
+
generated: undefined;
|
|
78
|
+
}, {}, {
|
|
79
|
+
length: 255;
|
|
80
|
+
}>;
|
|
81
|
+
signing_cert: import("drizzle-orm/pg-core").PgColumn<{
|
|
82
|
+
name: "signing_cert";
|
|
83
|
+
tableName: "auth_saml_service_providers";
|
|
84
|
+
dataType: "string";
|
|
85
|
+
columnType: "PgText";
|
|
86
|
+
data: string;
|
|
87
|
+
driverParam: string;
|
|
88
|
+
notNull: false;
|
|
89
|
+
hasDefault: false;
|
|
90
|
+
isPrimaryKey: false;
|
|
91
|
+
isAutoincrement: false;
|
|
92
|
+
hasRuntimeDefault: false;
|
|
93
|
+
enumValues: [string, ...string[]];
|
|
94
|
+
baseColumn: never;
|
|
95
|
+
identity: undefined;
|
|
96
|
+
generated: undefined;
|
|
97
|
+
}, {}, {}>;
|
|
98
|
+
updated_at_ms: import("drizzle-orm/pg-core").PgColumn<{
|
|
99
|
+
name: "updated_at_ms";
|
|
100
|
+
tableName: "auth_saml_service_providers";
|
|
101
|
+
dataType: "number";
|
|
102
|
+
columnType: "PgBigInt53";
|
|
103
|
+
data: number;
|
|
104
|
+
driverParam: string | number;
|
|
105
|
+
notNull: true;
|
|
106
|
+
hasDefault: false;
|
|
107
|
+
isPrimaryKey: false;
|
|
108
|
+
isAutoincrement: false;
|
|
109
|
+
hasRuntimeDefault: false;
|
|
110
|
+
enumValues: undefined;
|
|
111
|
+
baseColumn: never;
|
|
112
|
+
identity: undefined;
|
|
113
|
+
generated: undefined;
|
|
114
|
+
}, {}, {}>;
|
|
115
|
+
};
|
|
116
|
+
dialect: "pg";
|
|
117
|
+
}>;
|
|
118
|
+
export declare const createNeonSamlServiceProviderStore: (databaseUrl: string) => SamlServiceProviderStore;
|
|
119
|
+
export declare const createPostgresSamlServiceProviderStore: (db: AnyPgDatabase) => SamlServiceProviderStore;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { Elysia } from 'elysia';
|
|
2
|
+
import type { AuthSessionStore } from '../session/types';
|
|
3
|
+
import type { RouteString, SessionRecord } from '../types';
|
|
4
|
+
import { type SamlIdpAdapter } from './config';
|
|
5
|
+
import type { SamlServiceProviderStore } from './types';
|
|
6
|
+
type SamlIdpRoutesProps<UserType> = {
|
|
7
|
+
authSessionStore?: AuthSessionStore<UserType>;
|
|
8
|
+
getNameId: (user: UserType) => string;
|
|
9
|
+
getSamlAttributes?: (user: UserType) => Record<string, unknown>;
|
|
10
|
+
idpAdapter: SamlIdpAdapter;
|
|
11
|
+
idpEntityId: string;
|
|
12
|
+
loginUrl?: string;
|
|
13
|
+
samlServiceProviderStore: SamlServiceProviderStore;
|
|
14
|
+
ssoRoute?: RouteString;
|
|
15
|
+
};
|
|
16
|
+
export declare const samlIdpRoutes: <UserType>({ authSessionStore, getNameId, getSamlAttributes, idpAdapter, idpEntityId, loginUrl, samlServiceProviderStore, ssoRoute }: SamlIdpRoutesProps<UserType>) => Elysia<"", {
|
|
17
|
+
decorator: {};
|
|
18
|
+
store: {
|
|
19
|
+
session: SessionRecord<UserType>;
|
|
20
|
+
unregisteredSession: import("..").UnregisteredSessionRecord;
|
|
21
|
+
};
|
|
22
|
+
derive: {};
|
|
23
|
+
resolve: {};
|
|
24
|
+
}, {
|
|
25
|
+
typebox: {};
|
|
26
|
+
error: {};
|
|
27
|
+
}, {
|
|
28
|
+
schema: {};
|
|
29
|
+
standaloneSchema: {};
|
|
30
|
+
macro: {};
|
|
31
|
+
macroFn: {};
|
|
32
|
+
parser: {};
|
|
33
|
+
response: {};
|
|
34
|
+
}, {
|
|
35
|
+
[x: string]: {
|
|
36
|
+
post: {
|
|
37
|
+
body: {
|
|
38
|
+
RelayState?: string | undefined;
|
|
39
|
+
SAMLRequest?: string | undefined;
|
|
40
|
+
};
|
|
41
|
+
params: {};
|
|
42
|
+
query: unknown;
|
|
43
|
+
headers: unknown;
|
|
44
|
+
response: {
|
|
45
|
+
200: Response;
|
|
46
|
+
422: {
|
|
47
|
+
type: "validation";
|
|
48
|
+
on: string;
|
|
49
|
+
summary?: string;
|
|
50
|
+
message?: string;
|
|
51
|
+
found?: unknown;
|
|
52
|
+
property?: string;
|
|
53
|
+
expected?: string;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
} & {
|
|
59
|
+
[x: string]: {
|
|
60
|
+
get: {
|
|
61
|
+
body: unknown;
|
|
62
|
+
params: {};
|
|
63
|
+
query: {
|
|
64
|
+
RelayState?: string | undefined;
|
|
65
|
+
SAMLRequest?: string | undefined;
|
|
66
|
+
SigAlg?: string | undefined;
|
|
67
|
+
Signature?: string | undefined;
|
|
68
|
+
};
|
|
69
|
+
headers: unknown;
|
|
70
|
+
response: {
|
|
71
|
+
200: Response;
|
|
72
|
+
422: {
|
|
73
|
+
type: "validation";
|
|
74
|
+
on: string;
|
|
75
|
+
summary?: string;
|
|
76
|
+
message?: string;
|
|
77
|
+
found?: unknown;
|
|
78
|
+
property?: string;
|
|
79
|
+
expected?: string;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
} & {
|
|
85
|
+
[x: string]: {
|
|
86
|
+
get: {
|
|
87
|
+
body: unknown;
|
|
88
|
+
params: {};
|
|
89
|
+
query: {
|
|
90
|
+
RelayState?: string | undefined;
|
|
91
|
+
sp?: string | undefined;
|
|
92
|
+
};
|
|
93
|
+
headers: unknown;
|
|
94
|
+
response: {
|
|
95
|
+
200: Response;
|
|
96
|
+
422: {
|
|
97
|
+
type: "validation";
|
|
98
|
+
on: string;
|
|
99
|
+
summary?: string;
|
|
100
|
+
message?: string;
|
|
101
|
+
found?: unknown;
|
|
102
|
+
property?: string;
|
|
103
|
+
expected?: string;
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
} & {
|
|
109
|
+
[x: string]: {
|
|
110
|
+
get: {
|
|
111
|
+
body: unknown;
|
|
112
|
+
params: {};
|
|
113
|
+
query: unknown;
|
|
114
|
+
headers: unknown;
|
|
115
|
+
response: {
|
|
116
|
+
200: Response;
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
}, {
|
|
121
|
+
derive: {};
|
|
122
|
+
resolve: {};
|
|
123
|
+
schema: {};
|
|
124
|
+
standaloneSchema: {};
|
|
125
|
+
response: {};
|
|
126
|
+
}, {
|
|
127
|
+
derive: {};
|
|
128
|
+
resolve: {};
|
|
129
|
+
schema: {};
|
|
130
|
+
standaloneSchema: {};
|
|
131
|
+
response: {};
|
|
132
|
+
} & {
|
|
133
|
+
derive: {};
|
|
134
|
+
resolve: {};
|
|
135
|
+
schema: {};
|
|
136
|
+
standaloneSchema: {};
|
|
137
|
+
response: {};
|
|
138
|
+
}>;
|
|
139
|
+
export {};
|
package/dist/sso/types.d.ts
CHANGED
|
@@ -29,6 +29,20 @@ export type SamlConnection = SSOConnectionBase & {
|
|
|
29
29
|
type: 'saml';
|
|
30
30
|
};
|
|
31
31
|
export type SSOConnection = OidcConnection | SamlConnection;
|
|
32
|
+
export type SamlServiceProvider = {
|
|
33
|
+
acsUrl: string;
|
|
34
|
+
createdAt: number;
|
|
35
|
+
entityId: string;
|
|
36
|
+
nameIdFormat?: string;
|
|
37
|
+
signingCert?: string;
|
|
38
|
+
updatedAt: number;
|
|
39
|
+
};
|
|
40
|
+
export type SamlServiceProviderStore = {
|
|
41
|
+
deleteServiceProvider: (entityId: string) => Promise<void>;
|
|
42
|
+
findServiceProvider: (entityId: string) => Promise<SamlServiceProvider | undefined>;
|
|
43
|
+
listServiceProviders: () => Promise<SamlServiceProvider[]>;
|
|
44
|
+
saveServiceProvider: (sp: SamlServiceProvider) => Promise<void>;
|
|
45
|
+
};
|
|
32
46
|
export type SSOConnectionStore = {
|
|
33
47
|
deleteConnection: (connectionId: string) => Promise<void>;
|
|
34
48
|
getConnection: (connectionId: string) => Promise<SSOConnection | undefined>;
|
package/package.json
CHANGED