forked from dubinc/dub
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjackson.ts
More file actions
67 lines (62 loc) · 2.06 KB
/
jackson.ts
File metadata and controls
67 lines (62 loc) · 2.06 KB
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
import type {
IConnectionAPIController,
IDirectorySyncController,
IOAuthController,
ISPSAMLConfig,
JacksonOption,
} from "@boxyhq/saml-jackson";
import jackson from "@boxyhq/saml-jackson";
export const samlAudience = "https://saml.dub.co";
const opts: JacksonOption = {
externalUrl:
process.env.NODE_ENV === "production"
? "https://api.dub.co"
: `${process.env.NEXTAUTH_URL}`,
samlPath:
process.env.NODE_ENV === "production"
? "/auth/saml/callback"
: "/api/auth/saml/callback",
samlAudience,
db: {
engine: "planetscale",
type: "mysql",
url: process.env.DATABASE_URL as string,
ssl: {
rejectUnauthorized: false,
},
},
idpEnabled: true, // to allow folks to SSO directly from their IDP
scimPath:
process.env.NODE_ENV === "production" ? "/scim/v2.0" : "/api/scim/v2.0", // custom SCIM endpoint
clientSecretVerifier: process.env.NEXTAUTH_SECRET as string,
};
declare global {
var connectionController: IConnectionAPIController | undefined;
var apiController: IConnectionAPIController | undefined;
var oauthController: IOAuthController | undefined;
var samlSPConfig: ISPSAMLConfig | undefined;
var directorySyncController: IDirectorySyncController | undefined;
}
export default async function init() {
if (
!globalThis.connectionController ||
!globalThis.apiController ||
!globalThis.oauthController ||
!globalThis.samlSPConfig ||
!globalThis.directorySyncController
) {
const ret = await jackson(opts);
globalThis.connectionController = ret.connectionAPIController;
globalThis.apiController = ret.connectionAPIController;
globalThis.oauthController = ret.oauthController;
globalThis.samlSPConfig = ret.spConfig;
globalThis.directorySyncController = ret.directorySyncController;
}
return {
connectionController: globalThis.connectionController,
apiController: globalThis.apiController,
oauthController: globalThis.oauthController,
samlSPConfig: globalThis.samlSPConfig,
directorySyncController: globalThis.directorySyncController,
};
}