@boxyhq/saml-jackson 1.33.0 → 1.33.1-beta.1
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/controller/oauth/oidc-client.d.ts +3 -3
- package/dist/controller/oauth/oidc-client.js +2 -1
- package/dist/controller/oauth/oidc-client.js.map +1 -1
- package/dist/controller/oauth/oidc-issuer.d.ts +2 -0
- package/dist/controller/oauth/oidc-issuer.js +25 -0
- package/dist/controller/oauth/oidc-issuer.js.map +1 -0
- package/dist/controller/oauth.js +36 -35
- package/dist/controller/oauth.js.map +1 -1
- package/dist/controller/sso-handler.js +1 -1
- package/dist/controller/sso-handler.js.map +1 -1
- package/dist/controller/utils.d.ts +5 -3
- package/dist/controller/utils.js +10 -2
- package/dist/controller/utils.js.map +1 -1
- package/dist/src/controller/admin.d.ts +27 -0
- package/dist/src/controller/admin.js +60 -0
- package/dist/src/controller/admin.js.map +1 -0
- package/dist/src/controller/analytics.d.ts +16 -0
- package/dist/src/controller/analytics.js +79 -0
- package/dist/src/controller/analytics.js.map +1 -0
- package/dist/src/controller/api.d.ts +557 -0
- package/dist/src/controller/api.js +806 -0
- package/dist/src/controller/api.js.map +1 -0
- package/dist/src/controller/connection/oidc.d.ts +7 -0
- package/dist/src/controller/connection/oidc.js +181 -0
- package/dist/src/controller/connection/oidc.js.map +1 -0
- package/dist/src/controller/connection/saml.d.ts +7 -0
- package/dist/src/controller/connection/saml.js +250 -0
- package/dist/src/controller/connection/saml.js.map +1 -0
- package/dist/src/controller/error.d.ts +10 -0
- package/dist/src/controller/error.js +13 -0
- package/dist/src/controller/error.js.map +1 -0
- package/dist/src/controller/health-check.d.ts +11 -0
- package/dist/src/controller/health-check.js +51 -0
- package/dist/src/controller/health-check.js.map +1 -0
- package/dist/src/controller/logout.d.ts +18 -0
- package/dist/src/controller/logout.js +132 -0
- package/dist/src/controller/logout.js.map +1 -0
- package/dist/src/controller/oauth/allowed.d.ts +1 -0
- package/dist/src/controller/oauth/allowed.js +30 -0
- package/dist/src/controller/oauth/allowed.js.map +1 -0
- package/dist/src/controller/oauth/code-verifier.d.ts +1 -0
- package/dist/src/controller/oauth/code-verifier.js +8 -0
- package/dist/src/controller/oauth/code-verifier.js.map +1 -0
- package/dist/src/controller/oauth/oidc-client.d.ts +12 -0
- package/dist/src/controller/oauth/oidc-client.js +89 -0
- package/dist/src/controller/oauth/oidc-client.js.map +1 -0
- package/dist/src/controller/oauth/redirect.d.ts +1 -0
- package/dist/src/controller/oauth/redirect.js +13 -0
- package/dist/src/controller/oauth/redirect.js.map +1 -0
- package/dist/src/controller/oauth.d.ts +142 -0
- package/dist/src/controller/oauth.js +1112 -0
- package/dist/src/controller/oauth.js.map +1 -0
- package/dist/src/controller/oidc-discovery.d.ts +22 -0
- package/dist/src/controller/oidc-discovery.js +47 -0
- package/dist/src/controller/oidc-discovery.js.map +1 -0
- package/dist/src/controller/setup-link.d.ts +307 -0
- package/dist/src/controller/setup-link.js +462 -0
- package/dist/src/controller/setup-link.js.map +1 -0
- package/dist/src/controller/sp-config.d.ts +22 -0
- package/dist/src/controller/sp-config.js +89 -0
- package/dist/src/controller/sp-config.js.map +1 -0
- package/dist/src/controller/sso-handler.d.ts +66 -0
- package/dist/src/controller/sso-handler.js +306 -0
- package/dist/src/controller/sso-handler.js.map +1 -0
- package/dist/src/controller/utils.d.ts +84 -0
- package/dist/src/controller/utils.js +328 -0
- package/dist/src/controller/utils.js.map +1 -0
- package/dist/src/cron/lock.d.ts +18 -0
- package/dist/src/cron/lock.js +98 -0
- package/dist/src/cron/lock.js.map +1 -0
- package/dist/src/db/db.d.ts +5 -0
- package/dist/src/db/db.js +178 -0
- package/dist/src/db/db.js.map +1 -0
- package/dist/src/db/defaultDb.d.ts +2 -0
- package/dist/src/db/defaultDb.js +18 -0
- package/dist/src/db/defaultDb.js.map +1 -0
- package/dist/src/db/dynamoDb.d.ts +19 -0
- package/dist/src/db/dynamoDb.js +320 -0
- package/dist/src/db/dynamoDb.js.map +1 -0
- package/dist/src/db/encrypter.d.ts +3 -0
- package/dist/src/db/encrypter.js +22 -0
- package/dist/src/db/encrypter.js.map +1 -0
- package/dist/src/db/mem.d.ts +23 -0
- package/dist/src/db/mem.js +186 -0
- package/dist/src/db/mem.js.map +1 -0
- package/dist/src/db/mongo.d.ts +22 -0
- package/dist/src/db/mongo.js +177 -0
- package/dist/src/db/mongo.js.map +1 -0
- package/dist/src/db/planetscale/entity/JacksonIndex.d.ts +5 -0
- package/dist/src/db/planetscale/entity/JacksonIndex.js +32 -0
- package/dist/src/db/planetscale/entity/JacksonIndex.js.map +1 -0
- package/dist/src/db/planetscale/entity/JacksonStore.d.ts +9 -0
- package/dist/src/db/planetscale/entity/JacksonStore.js +63 -0
- package/dist/src/db/planetscale/entity/JacksonStore.js.map +1 -0
- package/dist/src/db/planetscale/entity/JacksonTTL.d.ts +4 -0
- package/dist/src/db/planetscale/entity/JacksonTTL.js +27 -0
- package/dist/src/db/planetscale/entity/JacksonTTL.js.map +1 -0
- package/dist/src/db/redis.d.ts +18 -0
- package/dist/src/db/redis.js +214 -0
- package/dist/src/db/redis.js.map +1 -0
- package/dist/src/db/sql/entity/JacksonIndex.d.ts +7 -0
- package/dist/src/db/sql/entity/JacksonIndex.js +39 -0
- package/dist/src/db/sql/entity/JacksonIndex.js.map +1 -0
- package/dist/src/db/sql/entity/JacksonStore.d.ts +9 -0
- package/dist/src/db/sql/entity/JacksonStore.js +61 -0
- package/dist/src/db/sql/entity/JacksonStore.js.map +1 -0
- package/dist/src/db/sql/entity/JacksonTTL.d.ts +4 -0
- package/dist/src/db/sql/entity/JacksonTTL.js +27 -0
- package/dist/src/db/sql/entity/JacksonTTL.js.map +1 -0
- package/dist/src/db/sql/mariadb/entity/JacksonIndex.d.ts +7 -0
- package/dist/src/db/sql/mariadb/entity/JacksonIndex.js +39 -0
- package/dist/src/db/sql/mariadb/entity/JacksonIndex.js.map +1 -0
- package/dist/src/db/sql/mariadb/entity/JacksonStore.d.ts +9 -0
- package/dist/src/db/sql/mariadb/entity/JacksonStore.js +63 -0
- package/dist/src/db/sql/mariadb/entity/JacksonStore.js.map +1 -0
- package/dist/src/db/sql/mariadb/entity/JacksonTTL.d.ts +4 -0
- package/dist/src/db/sql/mariadb/entity/JacksonTTL.js +27 -0
- package/dist/src/db/sql/mariadb/entity/JacksonTTL.js.map +1 -0
- package/dist/src/db/sql/mssql/entity/JacksonIndex.d.ts +7 -0
- package/dist/src/db/sql/mssql/entity/JacksonIndex.js +39 -0
- package/dist/src/db/sql/mssql/entity/JacksonIndex.js.map +1 -0
- package/dist/src/db/sql/mssql/entity/JacksonStore.d.ts +9 -0
- package/dist/src/db/sql/mssql/entity/JacksonStore.js +61 -0
- package/dist/src/db/sql/mssql/entity/JacksonStore.js.map +1 -0
- package/dist/src/db/sql/mssql/entity/JacksonTTL.d.ts +4 -0
- package/dist/src/db/sql/mssql/entity/JacksonTTL.js +27 -0
- package/dist/src/db/sql/mssql/entity/JacksonTTL.js.map +1 -0
- package/dist/src/db/sql/mssql.d.ts +1 -0
- package/dist/src/db/sql/mssql.js +44 -0
- package/dist/src/db/sql/mssql.js.map +1 -0
- package/dist/src/db/sql/sql.d.ts +32 -0
- package/dist/src/db/sql/sql.js +318 -0
- package/dist/src/db/sql/sql.js.map +1 -0
- package/dist/src/db/sql/sqlite/entity/JacksonIndex.d.ts +7 -0
- package/dist/src/db/sql/sqlite/entity/JacksonIndex.js +39 -0
- package/dist/src/db/sql/sqlite/entity/JacksonIndex.js.map +1 -0
- package/dist/src/db/sql/sqlite/entity/JacksonStore.d.ts +9 -0
- package/dist/src/db/sql/sqlite/entity/JacksonStore.js +61 -0
- package/dist/src/db/sql/sqlite/entity/JacksonStore.js.map +1 -0
- package/dist/src/db/sql/sqlite/entity/JacksonTTL.d.ts +4 -0
- package/dist/src/db/sql/sqlite/entity/JacksonTTL.js +27 -0
- package/dist/src/db/sql/sqlite/entity/JacksonTTL.js.map +1 -0
- package/dist/src/db/store.d.ts +5 -0
- package/dist/src/db/store.js +65 -0
- package/dist/src/db/store.js.map +1 -0
- package/dist/src/db/utils.d.ts +16 -0
- package/dist/src/db/utils.js +28 -0
- package/dist/src/db/utils.js.map +1 -0
- package/dist/src/directory-sync/batch-events/queue.d.ts +40 -0
- package/dist/src/directory-sync/batch-events/queue.js +225 -0
- package/dist/src/directory-sync/batch-events/queue.js.map +1 -0
- package/dist/src/directory-sync/index.d.ts +27 -0
- package/dist/src/directory-sync/index.js +97 -0
- package/dist/src/directory-sync/index.js.map +1 -0
- package/dist/src/directory-sync/non-scim/google/api.d.ts +36 -0
- package/dist/src/directory-sync/non-scim/google/api.js +143 -0
- package/dist/src/directory-sync/non-scim/google/api.js.map +1 -0
- package/dist/src/directory-sync/non-scim/google/index.d.ts +12 -0
- package/dist/src/directory-sync/non-scim/google/index.js +10 -0
- package/dist/src/directory-sync/non-scim/google/index.js.map +1 -0
- package/dist/src/directory-sync/non-scim/google/oauth.d.ts +27 -0
- package/dist/src/directory-sync/non-scim/google/oauth.js +105 -0
- package/dist/src/directory-sync/non-scim/google/oauth.js.map +1 -0
- package/dist/src/directory-sync/non-scim/index.d.ts +24 -0
- package/dist/src/directory-sync/non-scim/index.js +85 -0
- package/dist/src/directory-sync/non-scim/index.js.map +1 -0
- package/dist/src/directory-sync/non-scim/syncGroupMembers.d.ts +23 -0
- package/dist/src/directory-sync/non-scim/syncGroupMembers.js +105 -0
- package/dist/src/directory-sync/non-scim/syncGroupMembers.js.map +1 -0
- package/dist/src/directory-sync/non-scim/syncGroups.d.ts +24 -0
- package/dist/src/directory-sync/non-scim/syncGroups.js +120 -0
- package/dist/src/directory-sync/non-scim/syncGroups.js.map +1 -0
- package/dist/src/directory-sync/non-scim/syncUsers.d.ts +24 -0
- package/dist/src/directory-sync/non-scim/syncUsers.js +120 -0
- package/dist/src/directory-sync/non-scim/syncUsers.js.map +1 -0
- package/dist/src/directory-sync/non-scim/utils.d.ts +36 -0
- package/dist/src/directory-sync/non-scim/utils.js +109 -0
- package/dist/src/directory-sync/non-scim/utils.js.map +1 -0
- package/dist/src/directory-sync/request.d.ts +14 -0
- package/dist/src/directory-sync/request.js +29 -0
- package/dist/src/directory-sync/request.js.map +1 -0
- package/dist/src/directory-sync/scim/Base.d.ts +12 -0
- package/dist/src/directory-sync/scim/Base.js +23 -0
- package/dist/src/directory-sync/scim/Base.js.map +1 -0
- package/dist/src/directory-sync/scim/DirectoryConfig.d.ts +343 -0
- package/dist/src/directory-sync/scim/DirectoryConfig.js +580 -0
- package/dist/src/directory-sync/scim/DirectoryConfig.js.map +1 -0
- package/dist/src/directory-sync/scim/DirectoryGroups.d.ts +28 -0
- package/dist/src/directory-sync/scim/DirectoryGroups.js +252 -0
- package/dist/src/directory-sync/scim/DirectoryGroups.js.map +1 -0
- package/dist/src/directory-sync/scim/DirectoryUsers.d.ts +25 -0
- package/dist/src/directory-sync/scim/DirectoryUsers.js +193 -0
- package/dist/src/directory-sync/scim/DirectoryUsers.js.map +1 -0
- package/dist/src/directory-sync/scim/Groups.d.ts +166 -0
- package/dist/src/directory-sync/scim/Groups.js +348 -0
- package/dist/src/directory-sync/scim/Groups.js.map +1 -0
- package/dist/src/directory-sync/scim/Users.d.ts +99 -0
- package/dist/src/directory-sync/scim/Users.js +215 -0
- package/dist/src/directory-sync/scim/Users.js.map +1 -0
- package/dist/src/directory-sync/scim/WebhookEventsLogger.d.ts +101 -0
- package/dist/src/directory-sync/scim/WebhookEventsLogger.js +165 -0
- package/dist/src/directory-sync/scim/WebhookEventsLogger.js.map +1 -0
- package/dist/src/directory-sync/scim/transform.d.ts +6 -0
- package/dist/src/directory-sync/scim/transform.js +37 -0
- package/dist/src/directory-sync/scim/transform.js.map +1 -0
- package/dist/src/directory-sync/scim/utils.d.ts +33 -0
- package/dist/src/directory-sync/scim/utils.js +129 -0
- package/dist/src/directory-sync/scim/utils.js.map +1 -0
- package/dist/src/directory-sync/types.d.ts +195 -0
- package/dist/src/directory-sync/types.js +10 -0
- package/dist/src/directory-sync/types.js.map +1 -0
- package/dist/src/directory-sync/utils.d.ts +19 -0
- package/dist/src/directory-sync/utils.js +56 -0
- package/dist/src/directory-sync/utils.js.map +1 -0
- package/dist/src/ee/branding/index.d.ts +17 -0
- package/dist/src/ee/branding/index.js +49 -0
- package/dist/src/ee/branding/index.js.map +1 -0
- package/dist/src/ee/common/checkLicense.d.ts +3 -0
- package/dist/src/ee/common/checkLicense.js +23 -0
- package/dist/src/ee/common/checkLicense.js.map +1 -0
- package/dist/src/ee/identity-federation/app.d.ts +328 -0
- package/dist/src/ee/identity-federation/app.js +532 -0
- package/dist/src/ee/identity-federation/app.js.map +1 -0
- package/dist/src/ee/identity-federation/idp-login.d.ts +18 -0
- package/dist/src/ee/identity-federation/idp-login.js +98 -0
- package/dist/src/ee/identity-federation/idp-login.js.map +1 -0
- package/dist/src/ee/identity-federation/index.d.ts +15 -0
- package/dist/src/ee/identity-federation/index.js +43 -0
- package/dist/src/ee/identity-federation/index.js.map +1 -0
- package/dist/src/ee/identity-federation/sso.d.ts +24 -0
- package/dist/src/ee/identity-federation/sso.js +124 -0
- package/dist/src/ee/identity-federation/sso.js.map +1 -0
- package/dist/src/ee/identity-federation/types.d.ts +38 -0
- package/dist/src/ee/identity-federation/types.js +2 -0
- package/dist/src/ee/identity-federation/types.js.map +1 -0
- package/dist/src/ee/ory/ory.d.ts +18 -0
- package/dist/src/ee/ory/ory.js +195 -0
- package/dist/src/ee/ory/ory.js.map +1 -0
- package/dist/src/ee/product/index.d.ts +14 -0
- package/dist/src/ee/product/index.js +45 -0
- package/dist/src/ee/product/index.js.map +1 -0
- package/dist/src/event/axios.d.ts +2 -0
- package/dist/src/event/axios.js +27 -0
- package/dist/src/event/axios.js.map +1 -0
- package/dist/src/event/index.d.ts +11 -0
- package/dist/src/event/index.js +53 -0
- package/dist/src/event/index.js.map +1 -0
- package/dist/src/event/types.d.ts +21 -0
- package/dist/src/event/types.js +2 -0
- package/dist/src/event/types.js.map +1 -0
- package/dist/src/event/utils.d.ts +4 -0
- package/dist/src/event/utils.js +33 -0
- package/dist/src/event/utils.js.map +1 -0
- package/dist/src/event/webhook.d.ts +3 -0
- package/dist/src/event/webhook.js +34 -0
- package/dist/src/event/webhook.js.map +1 -0
- package/dist/src/index.d.ts +35 -0
- package/dist/src/index.js +161 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/loadConnection.d.ts +4 -0
- package/dist/src/loadConnection.js +38 -0
- package/dist/src/loadConnection.js.map +1 -0
- package/dist/src/opentelemetry/metrics.d.ts +14 -0
- package/dist/src/opentelemetry/metrics.js +64 -0
- package/dist/src/opentelemetry/metrics.js.map +1 -0
- package/dist/src/saml/claims.d.ts +12 -0
- package/dist/src/saml/claims.js +57 -0
- package/dist/src/saml/claims.js.map +1 -0
- package/dist/src/saml/lib.d.ts +8 -0
- package/dist/src/saml/lib.js +29 -0
- package/dist/src/saml/lib.js.map +1 -0
- package/dist/src/saml/x509.d.ts +9 -0
- package/dist/src/saml/x509.js +93 -0
- package/dist/src/saml/x509.js.map +1 -0
- package/dist/src/sso-traces/index.d.ts +114 -0
- package/dist/src/sso-traces/index.js +229 -0
- package/dist/src/sso-traces/index.js.map +1 -0
- package/dist/src/sso-traces/types.d.ts +44 -0
- package/dist/src/sso-traces/types.js +2 -0
- package/dist/src/sso-traces/types.js.map +1 -0
- package/dist/src/typings.d.ts +540 -0
- package/dist/src/typings.js +5 -0
- package/dist/src/typings.js.map +1 -0
- package/dist/typeorm.d.ts +3 -0
- package/dist/typeorm.js +58 -0
- package/dist/typeorm.js.map +1 -0
- package/dist/typings.d.ts +1 -1
- package/package.json +7 -7
@@ -0,0 +1,462 @@
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
|
+
});
|
9
|
+
};
|
10
|
+
import * as dbutils from '../db/utils';
|
11
|
+
import { IndexNames, validateTenantAndProduct, validateRedirectUrl, extractRedirectUrls } from './utils';
|
12
|
+
import crypto from 'crypto';
|
13
|
+
import { JacksonError } from './error';
|
14
|
+
const throwIfInvalidService = (service) => {
|
15
|
+
if (!['sso', 'dsync'].includes(service)) {
|
16
|
+
throw new JacksonError('Invalid service provided. Supported values are: sso, dsync', 400);
|
17
|
+
}
|
18
|
+
};
|
19
|
+
const calculateExpiryTimestamp = (expiryDays) => {
|
20
|
+
const currentTimestamp = Date.now();
|
21
|
+
return currentTimestamp + expiryDays * 24 * 60 * 60 * 1000;
|
22
|
+
};
|
23
|
+
/**
|
24
|
+
* @swagger
|
25
|
+
* definitions:
|
26
|
+
* SetupLink:
|
27
|
+
* type: object
|
28
|
+
* properties:
|
29
|
+
* setupID:
|
30
|
+
* type: string
|
31
|
+
* description: Setup link ID
|
32
|
+
* tenant:
|
33
|
+
* type: string
|
34
|
+
* description: Tenant
|
35
|
+
* product:
|
36
|
+
* type: string
|
37
|
+
* description: Product
|
38
|
+
* validTill:
|
39
|
+
* type: string
|
40
|
+
* description: Valid till timestamp
|
41
|
+
* url:
|
42
|
+
* type: string
|
43
|
+
* description: Setup link URL
|
44
|
+
*/
|
45
|
+
export class SetupLinkController {
|
46
|
+
constructor({ setupLinkStore, opts }) {
|
47
|
+
this.setupLinkStore = setupLinkStore;
|
48
|
+
this.opts = opts;
|
49
|
+
}
|
50
|
+
/**
|
51
|
+
* @swagger
|
52
|
+
* definitions:
|
53
|
+
* SetupLink:
|
54
|
+
* type: object
|
55
|
+
* example:
|
56
|
+
* {
|
57
|
+
* "data": {
|
58
|
+
* "setupID": "0689f76f7b5aa22f00381a124cb4b153fc1a8c08",
|
59
|
+
* "tenant": "acme",
|
60
|
+
* "product": "my-app",
|
61
|
+
* "service": "sso",
|
62
|
+
* "validTill": 1689849146690,
|
63
|
+
* "url": "http://localhost:5225/setup/0b96a483ebfe0af0b561dda35a96647074d944631ff9e070"
|
64
|
+
* }
|
65
|
+
* }
|
66
|
+
* parameters:
|
67
|
+
* tenantParamPost:
|
68
|
+
* name: tenant
|
69
|
+
* description: Tenant
|
70
|
+
* in: formData
|
71
|
+
* required: true
|
72
|
+
* type: string
|
73
|
+
* productParamPost:
|
74
|
+
* name: product
|
75
|
+
* description: Product
|
76
|
+
* in: formData
|
77
|
+
* required: true
|
78
|
+
* type: string
|
79
|
+
* defaultRedirectUrlParamPost:
|
80
|
+
* name: defaultRedirectUrl
|
81
|
+
* description: The redirect URL to use in the IdP login flow
|
82
|
+
* in: formData
|
83
|
+
* type: string
|
84
|
+
* required: true
|
85
|
+
* redirectUrlParamPost:
|
86
|
+
* name: redirectUrl
|
87
|
+
* description: JSON encoded array containing a list of allowed redirect URLs
|
88
|
+
* in: formData
|
89
|
+
* type: string
|
90
|
+
* required: true
|
91
|
+
* webhookUrlParamPost:
|
92
|
+
* name: webhook_url
|
93
|
+
* description: The URL to send the directory sync events to
|
94
|
+
* in: formData
|
95
|
+
* type: string
|
96
|
+
* required: true
|
97
|
+
* webhookSecretParamPost:
|
98
|
+
* name: webhook_secret
|
99
|
+
* description: The secret to sign the directory sync events
|
100
|
+
* in: formData
|
101
|
+
* type: string
|
102
|
+
* required: true
|
103
|
+
* nameParamPost:
|
104
|
+
* name: name
|
105
|
+
* description: Name of connection
|
106
|
+
* in: formData
|
107
|
+
* type: string
|
108
|
+
* required: false
|
109
|
+
* expiryDaysParamPost:
|
110
|
+
* name: expiryDays
|
111
|
+
* description: Days in number for the setup link to expire
|
112
|
+
* default: 3
|
113
|
+
* in: formData
|
114
|
+
* type: number
|
115
|
+
* required: false
|
116
|
+
* regenerateParamPost:
|
117
|
+
* name: regenerate
|
118
|
+
* description: If passed as true, it will remove the existing setup link and create a new one.
|
119
|
+
* in: formData
|
120
|
+
* default: false
|
121
|
+
* type: boolean
|
122
|
+
* required: false
|
123
|
+
* /api/v1/sso/setuplinks:
|
124
|
+
* post:
|
125
|
+
* summary: Create a Setup Link
|
126
|
+
* operationId: create-sso-setup-link
|
127
|
+
* tags: [Setup Links | Single Sign On]
|
128
|
+
* produces:
|
129
|
+
* - application/json
|
130
|
+
* consumes:
|
131
|
+
* - application/x-www-form-urlencoded
|
132
|
+
* - application/json
|
133
|
+
* parameters:
|
134
|
+
* - $ref: '#/parameters/nameParamPost'
|
135
|
+
* - $ref: '#/parameters/tenantParamPost'
|
136
|
+
* - $ref: '#/parameters/productParamPost'
|
137
|
+
* - $ref: '#/parameters/defaultRedirectUrlParamPost'
|
138
|
+
* - $ref: '#/parameters/redirectUrlParamPost'
|
139
|
+
* - $ref: '#/parameters/expiryDaysParamPost'
|
140
|
+
* - $ref: '#/parameters/regenerateParamPost'
|
141
|
+
* responses:
|
142
|
+
* 200:
|
143
|
+
* description: Success
|
144
|
+
* schema:
|
145
|
+
* $ref: '#/definitions/SetupLink'
|
146
|
+
* /api/v1/dsync/setuplinks:
|
147
|
+
* post:
|
148
|
+
* summary: Create a Setup Link
|
149
|
+
* operationId: create-dsync-setup-link
|
150
|
+
* tags: [Setup Links | Directory Sync]
|
151
|
+
* produces:
|
152
|
+
* - application/json
|
153
|
+
* consumes:
|
154
|
+
* - application/x-www-form-urlencoded
|
155
|
+
* - application/json
|
156
|
+
* parameters:
|
157
|
+
* - $ref: '#/parameters/nameParamPost'
|
158
|
+
* - $ref: '#/parameters/tenantParamPost'
|
159
|
+
* - $ref: '#/parameters/productParamPost'
|
160
|
+
* - $ref: '#/parameters/webhookUrlParamPost'
|
161
|
+
* - $ref: '#/parameters/webhookSecretParamPost'
|
162
|
+
* - $ref: '#/parameters/expiryDaysParamPost'
|
163
|
+
* - $ref: '#/parameters/regenerateParamPost'
|
164
|
+
* responses:
|
165
|
+
* 200:
|
166
|
+
* description: Success
|
167
|
+
* schema:
|
168
|
+
* $ref: '#/definitions/SetupLink'
|
169
|
+
*/
|
170
|
+
create(body) {
|
171
|
+
return __awaiter(this, void 0, void 0, function* () {
|
172
|
+
const { name, tenant, product, service, expiryDays, regenerate } = body;
|
173
|
+
validateTenantAndProduct(tenant, product);
|
174
|
+
throwIfInvalidService(service);
|
175
|
+
if (!tenant || !product) {
|
176
|
+
throw new JacksonError('Must provide tenant and product', 400);
|
177
|
+
}
|
178
|
+
if (service === 'sso') {
|
179
|
+
const { defaultRedirectUrl, redirectUrl } = body;
|
180
|
+
if (!defaultRedirectUrl || !redirectUrl) {
|
181
|
+
throw new JacksonError('Must provide defaultRedirectUrl and redirectUrl', 400);
|
182
|
+
}
|
183
|
+
validateRedirectUrl({ defaultRedirectUrl, redirectUrlList: extractRedirectUrls(redirectUrl || '') });
|
184
|
+
}
|
185
|
+
else if (service === 'dsync') {
|
186
|
+
const { webhook_url, webhook_secret } = body;
|
187
|
+
if (!webhook_url || !webhook_secret) {
|
188
|
+
throw new JacksonError('Must provide webhook_url and webhook_secret', 400);
|
189
|
+
}
|
190
|
+
}
|
191
|
+
const existing = (yield this.setupLinkStore.getByIndex({
|
192
|
+
name: IndexNames.TenantProductService,
|
193
|
+
value: dbutils.keyFromParts(tenant, product, service),
|
194
|
+
})).data;
|
195
|
+
if (existing.length > 0 && !regenerate && !this.isExpired(existing[0])) {
|
196
|
+
return existing[0];
|
197
|
+
}
|
198
|
+
// Remove the existing setup link if regenerate is true
|
199
|
+
if (existing.length > 0 && regenerate) {
|
200
|
+
yield this.setupLinkStore.delete(existing[0].setupID);
|
201
|
+
}
|
202
|
+
const token = crypto.randomBytes(24).toString('hex');
|
203
|
+
const expiryInDays = typeof expiryDays === 'number' && expiryDays > 0 ? expiryDays : this.opts.setupLinkExpiryDays || 3;
|
204
|
+
const setupID = dbutils.keyDigest(dbutils.keyFromParts(tenant, product, service));
|
205
|
+
const setupLink = {
|
206
|
+
setupID,
|
207
|
+
tenant,
|
208
|
+
product,
|
209
|
+
service,
|
210
|
+
name,
|
211
|
+
validTill: calculateExpiryTimestamp(expiryInDays),
|
212
|
+
url: `${this.opts.externalUrl}/setup/${token}`,
|
213
|
+
};
|
214
|
+
if (service === 'sso') {
|
215
|
+
const { defaultRedirectUrl, redirectUrl, description } = body;
|
216
|
+
setupLink.defaultRedirectUrl = defaultRedirectUrl;
|
217
|
+
setupLink.redirectUrl = redirectUrl;
|
218
|
+
setupLink.description = description || '';
|
219
|
+
}
|
220
|
+
else if (service === 'dsync') {
|
221
|
+
const { webhook_url, webhook_secret } = body;
|
222
|
+
setupLink.webhook_url = webhook_url;
|
223
|
+
setupLink.webhook_secret = webhook_secret;
|
224
|
+
}
|
225
|
+
yield this.setupLinkStore.put(setupID, setupLink, {
|
226
|
+
name: IndexNames.SetupToken,
|
227
|
+
value: token,
|
228
|
+
}, {
|
229
|
+
name: IndexNames.TenantProductService,
|
230
|
+
value: dbutils.keyFromParts(tenant, product, service),
|
231
|
+
}, {
|
232
|
+
name: IndexNames.Service,
|
233
|
+
value: service,
|
234
|
+
}, {
|
235
|
+
name: IndexNames.ProductService,
|
236
|
+
value: dbutils.keyFromParts(product, service),
|
237
|
+
});
|
238
|
+
return setupLink;
|
239
|
+
});
|
240
|
+
}
|
241
|
+
// Get a setup link by token
|
242
|
+
getByToken(token) {
|
243
|
+
return __awaiter(this, void 0, void 0, function* () {
|
244
|
+
if (!token) {
|
245
|
+
throw new JacksonError('Missing setup link token', 400);
|
246
|
+
}
|
247
|
+
const setupLink = (yield this.setupLinkStore.getByIndex({
|
248
|
+
name: IndexNames.SetupToken,
|
249
|
+
value: token,
|
250
|
+
})).data;
|
251
|
+
if (!setupLink || setupLink.length === 0) {
|
252
|
+
throw new JacksonError('Setup link is not found', 404);
|
253
|
+
}
|
254
|
+
if (this.isExpired(setupLink[0])) {
|
255
|
+
throw new JacksonError('Setup link is expired', 401);
|
256
|
+
}
|
257
|
+
return setupLink[0];
|
258
|
+
});
|
259
|
+
}
|
260
|
+
/**
|
261
|
+
* @swagger
|
262
|
+
* parameters:
|
263
|
+
* setupLinkId:
|
264
|
+
* name: id
|
265
|
+
* description: Setup link ID
|
266
|
+
* in: query
|
267
|
+
* required: false
|
268
|
+
* type: string
|
269
|
+
* /api/v1/sso/setuplinks:
|
270
|
+
* delete:
|
271
|
+
* summary: Delete the Setup Link
|
272
|
+
* parameters:
|
273
|
+
* - $ref: '#/parameters/tenantParamGet'
|
274
|
+
* - $ref: '#/parameters/productParamGet'
|
275
|
+
* - $ref: '#/parameters/setupLinkId'
|
276
|
+
* operationId: delete-sso-setup-link
|
277
|
+
* tags: [Setup Links | Single Sign On]
|
278
|
+
* responses:
|
279
|
+
* 200:
|
280
|
+
* description: Success
|
281
|
+
* schema:
|
282
|
+
* type: object
|
283
|
+
* example:
|
284
|
+
* {
|
285
|
+
* data: {}
|
286
|
+
* }
|
287
|
+
* /api/v1/dsync/setuplinks:
|
288
|
+
* delete:
|
289
|
+
* summary: Delete the Setup Link
|
290
|
+
* parameters:
|
291
|
+
* - $ref: '#/parameters/tenantParamGet'
|
292
|
+
* - $ref: '#/parameters/productParamGet'
|
293
|
+
* - $ref: '#/parameters/setupLinkId'
|
294
|
+
* operationId: delete-dsync-setup-link
|
295
|
+
* tags: [Setup Links | Directory Sync]
|
296
|
+
* responses:
|
297
|
+
* 200:
|
298
|
+
* description: Success
|
299
|
+
* schema:
|
300
|
+
* type: object
|
301
|
+
* example:
|
302
|
+
* {
|
303
|
+
* data: {}
|
304
|
+
* }
|
305
|
+
*/
|
306
|
+
remove(params) {
|
307
|
+
return __awaiter(this, void 0, void 0, function* () {
|
308
|
+
if ('id' in params) {
|
309
|
+
yield this.setupLinkStore.delete(params.id);
|
310
|
+
return;
|
311
|
+
}
|
312
|
+
if ('service' in params && 'tenant' in params && 'product' in params) {
|
313
|
+
const { data: setupLinks } = yield this.filterBy({
|
314
|
+
service: params.service,
|
315
|
+
tenant: params.tenant,
|
316
|
+
product: params.product,
|
317
|
+
});
|
318
|
+
yield this.remove({ id: setupLinks[0].setupID });
|
319
|
+
}
|
320
|
+
});
|
321
|
+
}
|
322
|
+
// Check if a setup link is expired or not
|
323
|
+
isExpired(setupLink) {
|
324
|
+
return setupLink.validTill < +new Date();
|
325
|
+
}
|
326
|
+
/**
|
327
|
+
* @swagger
|
328
|
+
* parameters:
|
329
|
+
* tenantParamGet:
|
330
|
+
* name: tenant
|
331
|
+
* description: Tenant
|
332
|
+
* in: query
|
333
|
+
* required: true
|
334
|
+
* type: string
|
335
|
+
* productParamGet:
|
336
|
+
* name: product
|
337
|
+
* description: Product
|
338
|
+
* in: query
|
339
|
+
* required: true
|
340
|
+
* type: string
|
341
|
+
* /api/v1/sso/setuplinks/product:
|
342
|
+
* get:
|
343
|
+
* summary: Get the Setup Links by product
|
344
|
+
* parameters:
|
345
|
+
* - $ref: '#/parameters/productParamGet'
|
346
|
+
* - $ref: '#/parameters/pageOffset'
|
347
|
+
* - $ref: '#/parameters/pageLimit'
|
348
|
+
* - $ref: '#/parameters/pageToken'
|
349
|
+
* operationId: get-sso-setup-link-by-product
|
350
|
+
* tags: [Setup Links | Single Sign On]
|
351
|
+
* responses:
|
352
|
+
* 200:
|
353
|
+
* description: Success
|
354
|
+
* schema:
|
355
|
+
* type: array
|
356
|
+
* items:
|
357
|
+
* $ref: '#/definitions/SetupLink'
|
358
|
+
* /api/v1/dsync/setuplinks/product:
|
359
|
+
* get:
|
360
|
+
* summary: Get the Setup Links by product
|
361
|
+
* parameters:
|
362
|
+
* - $ref: '#/parameters/productParamGet'
|
363
|
+
* - $ref: '#/parameters/pageOffset'
|
364
|
+
* - $ref: '#/parameters/pageLimit'
|
365
|
+
* - $ref: '#/parameters/pageToken'
|
366
|
+
* operationId: get-dsync-setup-link-by-product
|
367
|
+
* tags: [Setup Links | Directory Sync]
|
368
|
+
* responses:
|
369
|
+
* 200:
|
370
|
+
* description: Success
|
371
|
+
* schema:
|
372
|
+
* type: array
|
373
|
+
* items:
|
374
|
+
* $ref: '#/definitions/SetupLink'
|
375
|
+
*/
|
376
|
+
filterBy(params) {
|
377
|
+
return __awaiter(this, void 0, void 0, function* () {
|
378
|
+
const { tenant, product, service, pageOffset, pageLimit, pageToken } = params;
|
379
|
+
let index = null;
|
380
|
+
// By tenant + product + service
|
381
|
+
if (tenant && product && service) {
|
382
|
+
index = {
|
383
|
+
name: IndexNames.TenantProductService,
|
384
|
+
value: dbutils.keyFromParts(tenant, product, service),
|
385
|
+
};
|
386
|
+
}
|
387
|
+
// By product + service
|
388
|
+
else if (product && service) {
|
389
|
+
index = {
|
390
|
+
name: IndexNames.ProductService,
|
391
|
+
value: dbutils.keyFromParts(product, service),
|
392
|
+
};
|
393
|
+
}
|
394
|
+
// By service
|
395
|
+
else if (service) {
|
396
|
+
index = {
|
397
|
+
name: IndexNames.Service,
|
398
|
+
value: service,
|
399
|
+
};
|
400
|
+
}
|
401
|
+
if (!index) {
|
402
|
+
throw new JacksonError('Please provide either service or product to filter setup links', 400);
|
403
|
+
}
|
404
|
+
const { data: setupLinks, pageToken: nextPageToken } = yield this.setupLinkStore.getByIndex(index, pageOffset, pageLimit, pageToken);
|
405
|
+
if (index.name === IndexNames.TenantProductService && setupLinks.length === 0) {
|
406
|
+
throw new JacksonError('Setup link is not found', 404);
|
407
|
+
}
|
408
|
+
return { data: setupLinks, pageToken: nextPageToken };
|
409
|
+
});
|
410
|
+
}
|
411
|
+
/**
|
412
|
+
* @swagger
|
413
|
+
* parameters:
|
414
|
+
* idParamGet:
|
415
|
+
* name: id
|
416
|
+
* description: Setup Link ID
|
417
|
+
* in: query
|
418
|
+
* required: false
|
419
|
+
* type: string
|
420
|
+
* /api/v1/sso/setuplinks:
|
421
|
+
* get:
|
422
|
+
* summary: Get the Setup Link
|
423
|
+
* parameters:
|
424
|
+
* - $ref: '#/parameters/tenantParamGet'
|
425
|
+
* - $ref: '#/parameters/productParamGet'
|
426
|
+
* - $ref: '#/parameters/idParamGet'
|
427
|
+
* operationId: get-sso-setup-link
|
428
|
+
* tags: [Setup Links | Single Sign On]
|
429
|
+
* responses:
|
430
|
+
* 200:
|
431
|
+
* description: Success
|
432
|
+
* schema:
|
433
|
+
* $ref: '#/definitions/SetupLink'
|
434
|
+
* /api/v1/dsync/setuplinks:
|
435
|
+
* get:
|
436
|
+
* summary: Get the Setup Link
|
437
|
+
* parameters:
|
438
|
+
* - $ref: '#/parameters/tenantParamGet'
|
439
|
+
* - $ref: '#/parameters/productParamGet'
|
440
|
+
* - $ref: '#/parameters/idParamGet'
|
441
|
+
* operationId: get-dsync-setup-link
|
442
|
+
* tags: [Setup Links | Directory Sync]
|
443
|
+
* responses:
|
444
|
+
* 200:
|
445
|
+
* description: Success
|
446
|
+
* schema:
|
447
|
+
* $ref: '#/definitions/SetupLink'
|
448
|
+
*/
|
449
|
+
get(id) {
|
450
|
+
return __awaiter(this, void 0, void 0, function* () {
|
451
|
+
if (!id) {
|
452
|
+
throw new JacksonError('Missing setup link id', 400);
|
453
|
+
}
|
454
|
+
const setupLink = yield this.setupLinkStore.get(id);
|
455
|
+
if (!setupLink) {
|
456
|
+
throw new JacksonError('Setup link is not found', 404);
|
457
|
+
}
|
458
|
+
return setupLink;
|
459
|
+
});
|
460
|
+
}
|
461
|
+
}
|
462
|
+
//# sourceMappingURL=setup-link.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"setup-link.js","sourceRoot":"","sources":["../../../src/controller/setup-link.ts"],"names":[],"mappings":";;;;;;;;;AASA,OAAO,KAAK,OAAO,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACzG,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAkBvC,MAAM,qBAAqB,GAAG,CAAC,OAAe,EAAE,EAAE;IAChD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,IAAI,EAAE,UAAU,CAAC,OAAO;oBACxB,KAAK,EAAE,OAAO;iBACf,CAAC;YACJ,CAAC;YAED,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,MAAM,IAAI,YAAY,CAAC,gEAAgE,EAAE,GAAG,CAAC,CAAC;YAChG,CAAC;YAED,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,UAAU,CACzF,KAAK,EACL,UAAU,EACV,SAAS,EACT,SAAS,CACV,CAAC;YAEF,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,CAAC,oBAAoB,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC9E,MAAM,IAAI,YAAY,CAAC,yBAAyB,EAAE,GAAG,CAAC,CAAC;YACzD,CAAC;YAED,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;QACxD,CAAC;KAAA;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqCG;IACG,GAAG,CAAC,EAAU;;YAClB,IAAI,CAAC,EAAE,EAAE,CAAC;gBACR,MAAM,IAAI,YAAY,CAAC,uBAAuB,EAAE,GAAG,CAAC,CAAC;YACvD,CAAC;YAED,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAEpD,IAAI,CAAC,SAAS,EAAE,CAAC;gBACf,MAAM,IAAI,YAAY,CAAC,yBAAyB,EAAE,GAAG,CAAC,CAAC;YACzD,CAAC;YAED,OAAO,SAAS,CAAC;QACnB,CAAC;KAAA;CACF"}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import type { JacksonOption } from '../typings';
|
2
|
+
export declare class SPSSOConfig {
|
3
|
+
private opts;
|
4
|
+
constructor(opts: JacksonOption);
|
5
|
+
private get acsUrl();
|
6
|
+
private get entityId();
|
7
|
+
private get responseSigned();
|
8
|
+
private get assertionSignature();
|
9
|
+
private get signatureAlgorithm();
|
10
|
+
get oidcRedirectURI(): string;
|
11
|
+
get(): Promise<{
|
12
|
+
acsUrl: string;
|
13
|
+
entityId: string;
|
14
|
+
response: string;
|
15
|
+
assertionSignature: string;
|
16
|
+
signatureAlgorithm: string;
|
17
|
+
publicKey: string;
|
18
|
+
publicKeyString: string;
|
19
|
+
}>;
|
20
|
+
toMarkdown(): string;
|
21
|
+
toXMLMetadata(encryption?: boolean): Promise<string>;
|
22
|
+
}
|
@@ -0,0 +1,89 @@
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
|
+
});
|
9
|
+
};
|
10
|
+
import saml20 from '@boxyhq/saml20';
|
11
|
+
import { getDefaultCertificate } from '../saml/x509';
|
12
|
+
// Service Provider SSO Configuration
|
13
|
+
export class SPSSOConfig {
|
14
|
+
constructor(opts) {
|
15
|
+
this.opts = opts;
|
16
|
+
}
|
17
|
+
get acsUrl() {
|
18
|
+
return `${this.opts.externalUrl}${this.opts.samlPath}`;
|
19
|
+
}
|
20
|
+
get entityId() {
|
21
|
+
return `${this.opts.samlAudience}`;
|
22
|
+
}
|
23
|
+
get responseSigned() {
|
24
|
+
return 'Signed';
|
25
|
+
}
|
26
|
+
get assertionSignature() {
|
27
|
+
return 'Signed';
|
28
|
+
}
|
29
|
+
get signatureAlgorithm() {
|
30
|
+
return 'RSA-SHA256';
|
31
|
+
}
|
32
|
+
get oidcRedirectURI() {
|
33
|
+
return `${this.opts.externalUrl}${this.opts.oidcPath}`;
|
34
|
+
}
|
35
|
+
get() {
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
37
|
+
const cert = yield getDefaultCertificate();
|
38
|
+
return {
|
39
|
+
acsUrl: this.acsUrl,
|
40
|
+
entityId: this.entityId,
|
41
|
+
response: this.responseSigned,
|
42
|
+
assertionSignature: this.assertionSignature,
|
43
|
+
signatureAlgorithm: this.signatureAlgorithm,
|
44
|
+
publicKey: cert.publicKey,
|
45
|
+
publicKeyString: saml20.stripCertHeaderAndFooter(cert.publicKey),
|
46
|
+
};
|
47
|
+
});
|
48
|
+
}
|
49
|
+
toMarkdown() {
|
50
|
+
return markdownTemplate
|
51
|
+
.replace('{{acsUrl}}', this.acsUrl)
|
52
|
+
.replace('{{entityId}}', this.entityId)
|
53
|
+
.replace('{{responseSigned}}', this.responseSigned)
|
54
|
+
.replace('{{assertionSignature}}', this.assertionSignature)
|
55
|
+
.replace('{{signatureAlgorithm}}', this.signatureAlgorithm);
|
56
|
+
}
|
57
|
+
toXMLMetadata() {
|
58
|
+
return __awaiter(this, arguments, void 0, function* (encryption = false) {
|
59
|
+
const { entityId, acsUrl, publicKeyString } = yield this.get();
|
60
|
+
return saml20.createSPMetadataXML({ entityId, acsUrl, publicKeyString, encryption });
|
61
|
+
});
|
62
|
+
}
|
63
|
+
}
|
64
|
+
const markdownTemplate = `
|
65
|
+
## Service Provider (SP) SAML Configuration
|
66
|
+
|
67
|
+
Your Identity Provider (IdP) will ask for the following information while configuring the SAML application. Share this information with your IT administrator.
|
68
|
+
|
69
|
+
For provider specific instructions, refer to our <a href="https://boxyhq.com/docs/jackson/sso-providers" target="_blank">guides</a>
|
70
|
+
|
71
|
+
**ACS (Assertion Consumer Service) URL / Single Sign-On URL / Destination URL** <br />
|
72
|
+
{{acsUrl}}
|
73
|
+
|
74
|
+
**SP Entity ID / Identifier / Audience URI / Audience Restriction** <br />
|
75
|
+
{{entityId}}
|
76
|
+
|
77
|
+
**Response** <br />
|
78
|
+
{{responseSigned}}
|
79
|
+
|
80
|
+
**Assertion Signature** <br />
|
81
|
+
{{assertionSignature}}
|
82
|
+
|
83
|
+
**Signature Algorithm** <br />
|
84
|
+
{{signatureAlgorithm}}
|
85
|
+
|
86
|
+
**Assertion Encryption** <br />
|
87
|
+
If you want to encrypt the assertion, you can download our [public certificate](/.well-known/saml.cer). Otherwise select the 'Unencrypted' option.
|
88
|
+
`;
|
89
|
+
//# sourceMappingURL=sp-config.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"sp-config.js","sourceRoot":"","sources":["../../../src/controller/sp-config.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,MAAM,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD,qCAAqC;AACrC,MAAM,OAAO,WAAW;IACtB,YAAoB,IAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAE3C,IAAY,MAAM;QAChB,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;IACzD,CAAC;IAED,IAAY,QAAQ;QAClB,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;IACrC,CAAC;IAED,IAAY,cAAc;QACxB,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,IAAY,kBAAkB;QAC5B,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,IAAY,kBAAkB;QAC5B,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,IAAW,eAAe;QACxB,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;IACzD,CAAC;IAEY,GAAG;;YASd,MAAM,IAAI,GAAG,MAAM,qBAAqB,EAAE,CAAC;YAE3C,OAAO;gBACL,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,QAAQ,EAAE,IAAI,CAAC,cAAc;gBAC7B,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;gBAC3C,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;gBAC3C,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,eAAe,EAAE,MAAM,CAAC,wBAAwB,CAAC,IAAI,CAAC,SAAS,CAAC;aACjE,CAAC;QACJ,CAAC;KAAA;IAEM,UAAU;QACf,OAAO,gBAAgB;aACpB,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC;aAClC,OAAO,CAAC,cAAc,EAAE,IAAI,CAAC,QAAQ,CAAC;aACtC,OAAO,CAAC,oBAAoB,EAAE,IAAI,CAAC,cAAc,CAAC;aAClD,OAAO,CAAC,wBAAwB,EAAE,IAAI,CAAC,kBAAkB,CAAC;aAC1D,OAAO,CAAC,wBAAwB,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAChE,CAAC;IAEY,aAAa;6DAAC,UAAU,GAAG,KAAK;YAC3C,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC;YAE/D,OAAO,MAAM,CAAC,mBAAmB,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE,UAAU,EAAE,CAAC,CAAC;QACvF,CAAC;KAAA;CACF;AAED,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;CAwBxB,CAAC"}
|
@@ -0,0 +1,66 @@
|
|
1
|
+
import type { SAMLProfile } from '@boxyhq/saml20/dist/typings';
|
2
|
+
import type { JacksonOption, Storable, SAMLSSORecord, OIDCSSORecord, IdentityFederationApp, SSOTracesInstance, SSOTrace } from '../typings';
|
3
|
+
export declare class SSOHandler {
|
4
|
+
private connection;
|
5
|
+
private session;
|
6
|
+
private opts;
|
7
|
+
constructor({ connection, session, opts, }: {
|
8
|
+
connection: Storable;
|
9
|
+
session: Storable;
|
10
|
+
opts: JacksonOption;
|
11
|
+
});
|
12
|
+
resolveConnection(params: {
|
13
|
+
authFlow: 'oauth' | 'saml' | 'idp-initiated';
|
14
|
+
originalParams: Record<string, any>;
|
15
|
+
tenant?: string;
|
16
|
+
product?: string;
|
17
|
+
entityId?: string;
|
18
|
+
iss?: string;
|
19
|
+
idp_hint?: string;
|
20
|
+
idFedAppId?: string;
|
21
|
+
fedType?: string;
|
22
|
+
thirdPartyLogin?: {
|
23
|
+
idpInitiatorType?: 'oidc' | 'saml';
|
24
|
+
iss?: string;
|
25
|
+
target_link_uri?: string;
|
26
|
+
};
|
27
|
+
tenants?: string[];
|
28
|
+
ssoTraces?: {
|
29
|
+
instance: SSOTracesInstance;
|
30
|
+
context: SSOTrace['context'];
|
31
|
+
};
|
32
|
+
}): Promise<{
|
33
|
+
connection: SAMLSSORecord | OIDCSSORecord;
|
34
|
+
} | {
|
35
|
+
redirectUrl: string;
|
36
|
+
} | {
|
37
|
+
postForm: string;
|
38
|
+
}>;
|
39
|
+
createSAMLRequest({ connection, requestParams, mappings, }: {
|
40
|
+
connection: SAMLSSORecord;
|
41
|
+
requestParams: Record<string, any>;
|
42
|
+
mappings: IdentityFederationApp['mappings'];
|
43
|
+
}): Promise<{
|
44
|
+
redirect_url: any;
|
45
|
+
authorize_form: any;
|
46
|
+
}>;
|
47
|
+
createOIDCRequest({ connection, requestParams, mappings, ssoTraces, }: {
|
48
|
+
connection: OIDCSSORecord;
|
49
|
+
requestParams: Record<string, any>;
|
50
|
+
mappings: IdentityFederationApp['mappings'];
|
51
|
+
ssoTraces: {
|
52
|
+
instance: SSOTracesInstance;
|
53
|
+
context: SSOTrace['context'];
|
54
|
+
};
|
55
|
+
}): Promise<{
|
56
|
+
redirect_url: any;
|
57
|
+
authorize_form: null;
|
58
|
+
}>;
|
59
|
+
createSAMLResponse: ({ profile, session }: {
|
60
|
+
profile: SAMLProfile;
|
61
|
+
session: any;
|
62
|
+
}) => Promise<{
|
63
|
+
responseForm: any;
|
64
|
+
}>;
|
65
|
+
private createSession;
|
66
|
+
}
|