@boxyhq/saml-jackson 1.32.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/api.js +17 -7
- package/dist/controller/api.js.map +1 -1
- package/dist/controller/connection/oidc.js +17 -7
- package/dist/controller/connection/oidc.js.map +1 -1
- package/dist/controller/connection/saml.js +17 -7
- package/dist/controller/connection/saml.js.map +1 -1
- package/dist/controller/logout.js +17 -7
- package/dist/controller/logout.js.map +1 -1
- package/dist/controller/oauth/oidc-client.d.ts +9 -4
- package/dist/controller/oauth/oidc-client.js +80 -11
- 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 +97 -46
- package/dist/controller/oauth.js.map +1 -1
- package/dist/controller/setup-link.js +17 -7
- package/dist/controller/setup-link.js.map +1 -1
- package/dist/controller/sso-handler.d.ts +10 -2
- package/dist/controller/sso-handler.js +34 -12
- package/dist/controller/sso-handler.js.map +1 -1
- package/dist/controller/utils.d.ts +5 -3
- package/dist/controller/utils.js +27 -9
- package/dist/controller/utils.js.map +1 -1
- package/dist/db/db.js +17 -7
- package/dist/db/db.js.map +1 -1
- package/dist/db/dynamoDb.js +17 -7
- package/dist/db/dynamoDb.js.map +1 -1
- package/dist/db/mem.js +17 -7
- package/dist/db/mem.js.map +1 -1
- package/dist/db/mongo.js +17 -7
- package/dist/db/mongo.js.map +1 -1
- package/dist/db/redis.js +17 -7
- package/dist/db/redis.js.map +1 -1
- package/dist/db/sql/sql.js +17 -7
- package/dist/db/sql/sql.js.map +1 -1
- package/dist/db/store.js +17 -7
- package/dist/db/store.js.map +1 -1
- package/dist/directory-sync/batch-events/queue.js +17 -7
- package/dist/directory-sync/batch-events/queue.js.map +1 -1
- package/dist/directory-sync/scim/DirectoryConfig.js +17 -7
- package/dist/directory-sync/scim/DirectoryConfig.js.map +1 -1
- package/dist/directory-sync/scim/Groups.js +17 -7
- package/dist/directory-sync/scim/Groups.js.map +1 -1
- package/dist/ee/identity-federation/idp-login.js +20 -14
- package/dist/ee/identity-federation/idp-login.js.map +1 -1
- package/dist/ee/identity-federation/sso.js +16 -11
- package/dist/ee/identity-federation/sso.js.map +1 -1
- package/dist/event/axios.d.ts +2 -1
- package/dist/index.js +17 -7
- package/dist/index.js.map +1 -1
- package/dist/loadConnection.js +17 -7
- package/dist/loadConnection.js.map +1 -1
- package/dist/saml/lib.js +17 -7
- package/dist/saml/lib.js.map +1 -1
- package/dist/saml/x509.js +17 -7
- package/dist/saml/x509.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 +13 -13
@@ -0,0 +1,252 @@
|
|
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 { parseGroupOperation } from './utils';
|
11
|
+
import { sendEvent } from '../utils';
|
12
|
+
import { isConnectionActive } from '../../controller/utils';
|
13
|
+
export class DirectoryGroups {
|
14
|
+
constructor({ directories, users, groups }) {
|
15
|
+
this.directories = directories;
|
16
|
+
this.users = users;
|
17
|
+
this.groups = groups;
|
18
|
+
}
|
19
|
+
create(directory, body) {
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
21
|
+
const { displayName, groupId } = body;
|
22
|
+
// Check if the group already exists
|
23
|
+
const { data: groups } = yield this.groups.search(displayName, directory.id);
|
24
|
+
if (groups && groups.length > 0) {
|
25
|
+
return this.respondWithError({ code: 409, message: 'Group already exists' });
|
26
|
+
}
|
27
|
+
const { data: group } = yield this.groups.create({
|
28
|
+
directoryId: directory.id,
|
29
|
+
name: displayName,
|
30
|
+
id: groupId,
|
31
|
+
raw: 'rawAttributes' in body ? body.rawAttributes : Object.assign(Object.assign({}, body), { members: [] }),
|
32
|
+
});
|
33
|
+
yield sendEvent('group.created', { directory, group }, this.callback);
|
34
|
+
return {
|
35
|
+
status: 201,
|
36
|
+
data: {
|
37
|
+
schemas: ['urn:ietf:params:scim:schemas:core:2.0:Group'],
|
38
|
+
id: group === null || group === void 0 ? void 0 : group.id,
|
39
|
+
displayName: group === null || group === void 0 ? void 0 : group.name,
|
40
|
+
members: [],
|
41
|
+
},
|
42
|
+
};
|
43
|
+
});
|
44
|
+
}
|
45
|
+
get(group) {
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
47
|
+
return {
|
48
|
+
status: 200,
|
49
|
+
data: {
|
50
|
+
schemas: ['urn:ietf:params:scim:schemas:core:2.0:Group'],
|
51
|
+
id: group.id,
|
52
|
+
displayName: group.name,
|
53
|
+
members: [],
|
54
|
+
},
|
55
|
+
};
|
56
|
+
});
|
57
|
+
}
|
58
|
+
getAll(queryParams) {
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
60
|
+
const { filter, directoryId } = queryParams;
|
61
|
+
let groups = [];
|
62
|
+
if (filter) {
|
63
|
+
// Filter by group displayName
|
64
|
+
// filter: displayName eq "Developer"
|
65
|
+
const { data } = yield this.groups.search(filter.split('eq ')[1].replace(/['"]+/g, ''), directoryId);
|
66
|
+
groups = data;
|
67
|
+
}
|
68
|
+
else {
|
69
|
+
// Fetch all the existing group
|
70
|
+
const { data } = yield this.groups.getAll({ directoryId, pageOffset: undefined, pageLimit: undefined });
|
71
|
+
groups = data;
|
72
|
+
}
|
73
|
+
return {
|
74
|
+
status: 200,
|
75
|
+
data: {
|
76
|
+
schemas: ['urn:ietf:params:scim:api:messages:2.0:ListResponse'],
|
77
|
+
totalResults: groups ? groups.length : 0,
|
78
|
+
itemsPerPage: groups ? groups.length : 0,
|
79
|
+
startIndex: 1,
|
80
|
+
Resources: groups ? groups.map((group) => group.raw) : [],
|
81
|
+
},
|
82
|
+
};
|
83
|
+
});
|
84
|
+
}
|
85
|
+
patch(directory, group, body) {
|
86
|
+
return __awaiter(this, void 0, void 0, function* () {
|
87
|
+
const { Operations } = body;
|
88
|
+
for (const op of Operations) {
|
89
|
+
const operation = parseGroupOperation(op);
|
90
|
+
// Add group members
|
91
|
+
if (operation.action === 'addGroupMember') {
|
92
|
+
yield this.addGroupMembers(directory, group, operation.members);
|
93
|
+
}
|
94
|
+
// Remove group members
|
95
|
+
if (operation.action === 'removeGroupMember') {
|
96
|
+
yield this.removeGroupMembers(directory, group, operation.members);
|
97
|
+
}
|
98
|
+
// Update group name
|
99
|
+
if (operation.action === 'updateGroupName') {
|
100
|
+
yield this.updateDisplayName(directory, group, {
|
101
|
+
displayName: operation.displayName,
|
102
|
+
});
|
103
|
+
}
|
104
|
+
}
|
105
|
+
const { data: updatedGroup } = yield this.groups.get(group.id);
|
106
|
+
return {
|
107
|
+
status: 200,
|
108
|
+
data: {
|
109
|
+
schemas: ['urn:ietf:params:scim:schemas:core:2.0:Group'],
|
110
|
+
id: updatedGroup === null || updatedGroup === void 0 ? void 0 : updatedGroup.id,
|
111
|
+
displayName: updatedGroup === null || updatedGroup === void 0 ? void 0 : updatedGroup.name,
|
112
|
+
members: [],
|
113
|
+
},
|
114
|
+
};
|
115
|
+
});
|
116
|
+
}
|
117
|
+
update(directory, group, body) {
|
118
|
+
return __awaiter(this, void 0, void 0, function* () {
|
119
|
+
const updatedGroup = yield this.updateDisplayName(directory, group, body);
|
120
|
+
return {
|
121
|
+
status: 200,
|
122
|
+
data: {
|
123
|
+
schemas: ['urn:ietf:params:scim:schemas:core:2.0:Group'],
|
124
|
+
id: group.id,
|
125
|
+
displayName: updatedGroup.name,
|
126
|
+
members: [],
|
127
|
+
},
|
128
|
+
};
|
129
|
+
});
|
130
|
+
}
|
131
|
+
delete(directory, group) {
|
132
|
+
return __awaiter(this, void 0, void 0, function* () {
|
133
|
+
yield this.groups.delete(group.id);
|
134
|
+
yield sendEvent('group.deleted', { directory, group }, this.callback);
|
135
|
+
return {
|
136
|
+
status: 200,
|
137
|
+
data: {},
|
138
|
+
};
|
139
|
+
});
|
140
|
+
}
|
141
|
+
// Update group displayName
|
142
|
+
updateDisplayName(directory, group, body) {
|
143
|
+
return __awaiter(this, void 0, void 0, function* () {
|
144
|
+
const { data: updatedGroup, error } = yield this.groups.update(group.id, {
|
145
|
+
name: body.displayName,
|
146
|
+
raw: 'rawAttributes' in body ? body.rawAttributes : Object.assign(Object.assign({}, group.raw), body),
|
147
|
+
});
|
148
|
+
if (error || !updatedGroup) {
|
149
|
+
throw error;
|
150
|
+
}
|
151
|
+
yield sendEvent('group.updated', { directory, group: updatedGroup }, this.callback);
|
152
|
+
return updatedGroup;
|
153
|
+
});
|
154
|
+
}
|
155
|
+
addGroupMembers(directory, group, members) {
|
156
|
+
return __awaiter(this, void 0, void 0, function* () {
|
157
|
+
if (members === undefined || (members && members.length === 0)) {
|
158
|
+
return;
|
159
|
+
}
|
160
|
+
for (const member of members) {
|
161
|
+
if (!(yield this.groups.isUserInGroup(group.id, member.value))) {
|
162
|
+
yield this.groups.addUserToGroup(group.id, member.value);
|
163
|
+
}
|
164
|
+
const { data: user } = yield this.users.get(member.value);
|
165
|
+
yield sendEvent('group.user_added', { directory, group, user }, this.callback);
|
166
|
+
}
|
167
|
+
});
|
168
|
+
}
|
169
|
+
removeGroupMembers(directory, group, members) {
|
170
|
+
return __awaiter(this, void 0, void 0, function* () {
|
171
|
+
if (members === undefined || (members && members.length === 0)) {
|
172
|
+
return;
|
173
|
+
}
|
174
|
+
for (const member of members) {
|
175
|
+
yield this.groups.removeUserFromGroup(group.id, member.value);
|
176
|
+
const { data: user } = yield this.users.get(member.value);
|
177
|
+
// User may not exist in the directory, so we need to check if the user exists
|
178
|
+
if (user) {
|
179
|
+
yield sendEvent('group.user_removed', { directory, group, user }, this.callback);
|
180
|
+
}
|
181
|
+
}
|
182
|
+
});
|
183
|
+
}
|
184
|
+
respondWithError(error) {
|
185
|
+
return {
|
186
|
+
status: error ? error.code : 500,
|
187
|
+
data: {
|
188
|
+
schemas: ['urn:ietf:params:scim:api:messages:2.0:Error'],
|
189
|
+
detail: error ? error.message : 'Internal Server Error',
|
190
|
+
},
|
191
|
+
};
|
192
|
+
}
|
193
|
+
// Handle the request from the Identity Provider and route it to the appropriate method
|
194
|
+
handleRequest(request, callback) {
|
195
|
+
return __awaiter(this, void 0, void 0, function* () {
|
196
|
+
const { body, query, resourceId: groupId, directoryId, apiSecret } = request;
|
197
|
+
const method = request.method.toUpperCase();
|
198
|
+
// Get the directory
|
199
|
+
const { data: directory, error } = yield this.directories.get(directoryId);
|
200
|
+
if (error) {
|
201
|
+
return this.respondWithError(error);
|
202
|
+
}
|
203
|
+
if (!directory) {
|
204
|
+
return {
|
205
|
+
status: 200,
|
206
|
+
data: {},
|
207
|
+
};
|
208
|
+
}
|
209
|
+
if (!isConnectionActive(directory)) {
|
210
|
+
return {
|
211
|
+
status: 200,
|
212
|
+
data: {},
|
213
|
+
};
|
214
|
+
}
|
215
|
+
// Validate the request
|
216
|
+
if (directory.scim.secret != apiSecret) {
|
217
|
+
return this.respondWithError({ code: 401, message: 'Unauthorized' });
|
218
|
+
}
|
219
|
+
this.callback = callback;
|
220
|
+
this.users.setTenantAndProduct(directory.tenant, directory.product);
|
221
|
+
this.groups.setTenantAndProduct(directory.tenant, directory.product);
|
222
|
+
// Get the group
|
223
|
+
const { data: group } = groupId ? yield this.groups.get(groupId) : { data: null };
|
224
|
+
if (groupId && !group) {
|
225
|
+
return this.respondWithError({ code: 404, message: 'Group not found' });
|
226
|
+
}
|
227
|
+
if (group) {
|
228
|
+
switch (method) {
|
229
|
+
case 'GET':
|
230
|
+
return yield this.get(group);
|
231
|
+
case 'PUT':
|
232
|
+
return yield this.update(directory, group, body);
|
233
|
+
case 'PATCH':
|
234
|
+
return yield this.patch(directory, group, body);
|
235
|
+
case 'DELETE':
|
236
|
+
return yield this.delete(directory, group);
|
237
|
+
}
|
238
|
+
}
|
239
|
+
switch (method) {
|
240
|
+
case 'POST':
|
241
|
+
return yield this.create(directory, body);
|
242
|
+
case 'GET':
|
243
|
+
return yield this.getAll({
|
244
|
+
filter: query.filter,
|
245
|
+
directoryId,
|
246
|
+
});
|
247
|
+
}
|
248
|
+
return this.respondWithError({ code: 404, message: 'Not found' });
|
249
|
+
});
|
250
|
+
}
|
251
|
+
}
|
252
|
+
//# sourceMappingURL=DirectoryGroups.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"DirectoryGroups.js","sourceRoot":"","sources":["../../../../src/directory-sync/scim/DirectoryGroups.ts"],"names":[],"mappings":";;;;;;;;;AAaA,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAQ5D,MAAM,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AAK,CAAC,CAAC;oBAC/B,KAAK,KAAK;wBACR,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;oBACnD,KAAK,OAAO;wBACV,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;oBAClD,KAAK,QAAQ;wBACX,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;gBAC/C,CAAC;YACH,CAAC;YAED,QAAQ,MAAM,EAAE,CAAC;gBACf,KAAK,MAAM;oBACT,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;gBAC5C,KAAK,KAAK;oBACR,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC;wBACvB,MAAM,EAAE,KAAK,CAAC,MAAM;wBACpB,WAAW;qBACZ,CAAC,CAAC;YACP,CAAC;YAED,OAAO,IAAI,CAAC,gBAAgB,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;QACpE,CAAC;KAAA;CACF"}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import type { Directory, DirectorySyncResponse, DirectorySyncRequest, User, EventCallback, IDirectoryConfig, IUsers } from '../../typings';
|
2
|
+
interface DirectoryUsersParams {
|
3
|
+
directories: IDirectoryConfig;
|
4
|
+
users: IUsers;
|
5
|
+
}
|
6
|
+
export declare class DirectoryUsers {
|
7
|
+
private directories;
|
8
|
+
private users;
|
9
|
+
private callback;
|
10
|
+
constructor({ directories, users }: DirectoryUsersParams);
|
11
|
+
create(directory: Directory, body: any): Promise<DirectorySyncResponse>;
|
12
|
+
get(user: User): Promise<DirectorySyncResponse>;
|
13
|
+
update(directory: Directory, user: User, body: any): Promise<DirectorySyncResponse>;
|
14
|
+
patch(directory: Directory, user: User, body: any): Promise<DirectorySyncResponse>;
|
15
|
+
delete(directory: Directory, user: User): Promise<DirectorySyncResponse>;
|
16
|
+
getAll(queryParams: {
|
17
|
+
count: number;
|
18
|
+
startIndex: number;
|
19
|
+
filter?: string;
|
20
|
+
directoryId: string;
|
21
|
+
}): Promise<DirectorySyncResponse>;
|
22
|
+
private respondWithError;
|
23
|
+
handleRequest(request: DirectorySyncRequest, callback?: EventCallback): Promise<DirectorySyncResponse>;
|
24
|
+
}
|
25
|
+
export {};
|
@@ -0,0 +1,193 @@
|
|
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 { parseUserPatchRequest, extractStandardUserAttributes, updateRawUserAttributes } from './utils';
|
11
|
+
import { sendEvent } from '../utils';
|
12
|
+
import { isConnectionActive } from '../../controller/utils';
|
13
|
+
import { randomUUID } from 'crypto';
|
14
|
+
export class DirectoryUsers {
|
15
|
+
constructor({ directories, users }) {
|
16
|
+
this.directories = directories;
|
17
|
+
this.users = users;
|
18
|
+
}
|
19
|
+
create(directory, body) {
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
21
|
+
const userAttributes = extractStandardUserAttributes(body);
|
22
|
+
// Check if the user already exists
|
23
|
+
const { data: users } = yield this.users.search(userAttributes.email, directory.id);
|
24
|
+
if (users && users.length > 0) {
|
25
|
+
return this.respondWithError({ code: 409, message: 'User already exists' });
|
26
|
+
}
|
27
|
+
const newUser = Object.assign(Object.assign({}, userAttributes), { directoryId: directory.id, raw: 'rawAttributes' in body ? body.rawAttributes : body });
|
28
|
+
if (!newUser.id) {
|
29
|
+
newUser.id = randomUUID();
|
30
|
+
}
|
31
|
+
newUser.raw['id'] = newUser.id;
|
32
|
+
const { data: user } = yield this.users.create(newUser);
|
33
|
+
yield sendEvent('user.created', { directory, user }, this.callback);
|
34
|
+
return {
|
35
|
+
status: 201,
|
36
|
+
data: user === null || user === void 0 ? void 0 : user.raw,
|
37
|
+
};
|
38
|
+
});
|
39
|
+
}
|
40
|
+
get(user) {
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
42
|
+
return {
|
43
|
+
status: 200,
|
44
|
+
data: user.raw,
|
45
|
+
};
|
46
|
+
});
|
47
|
+
}
|
48
|
+
update(directory, user, body) {
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
50
|
+
const userAttributes = extractStandardUserAttributes(body);
|
51
|
+
const { data: updatedUser } = yield this.users.update(user.id, Object.assign(Object.assign({}, userAttributes), { id: user.id, raw: 'rawAttributes' in body ? body.rawAttributes : body }));
|
52
|
+
yield sendEvent('user.updated', { directory, user: updatedUser }, this.callback);
|
53
|
+
return {
|
54
|
+
status: 200,
|
55
|
+
data: updatedUser === null || updatedUser === void 0 ? void 0 : updatedUser.raw,
|
56
|
+
};
|
57
|
+
});
|
58
|
+
}
|
59
|
+
patch(directory, user, body) {
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
61
|
+
const { Operations } = body;
|
62
|
+
let attributes = {};
|
63
|
+
let rawAttributes = {};
|
64
|
+
// There can be multiple update operations in a single request for a user
|
65
|
+
for (const operation of Operations) {
|
66
|
+
const parsedAttributes = parseUserPatchRequest(operation);
|
67
|
+
attributes = Object.assign(Object.assign({}, attributes), parsedAttributes.attributes);
|
68
|
+
rawAttributes = Object.assign(Object.assign({}, rawAttributes), parsedAttributes.rawAttributes);
|
69
|
+
}
|
70
|
+
const { data: updatedUser } = yield this.users.update(user.id, Object.assign(Object.assign(Object.assign({}, user), attributes), { raw: updateRawUserAttributes(user.raw, rawAttributes) }));
|
71
|
+
yield sendEvent('user.updated', { directory, user: updatedUser }, this.callback);
|
72
|
+
return {
|
73
|
+
status: 200,
|
74
|
+
data: updatedUser === null || updatedUser === void 0 ? void 0 : updatedUser.raw,
|
75
|
+
};
|
76
|
+
});
|
77
|
+
}
|
78
|
+
delete(directory, user) {
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
80
|
+
yield this.users.delete(user.id);
|
81
|
+
yield sendEvent('user.deleted', { directory, user }, this.callback);
|
82
|
+
return {
|
83
|
+
status: 200,
|
84
|
+
data: user.raw,
|
85
|
+
};
|
86
|
+
});
|
87
|
+
}
|
88
|
+
getAll(queryParams) {
|
89
|
+
return __awaiter(this, void 0, void 0, function* () {
|
90
|
+
const { startIndex, filter, count, directoryId } = queryParams;
|
91
|
+
let users = [];
|
92
|
+
let totalResults = 0;
|
93
|
+
if (filter) {
|
94
|
+
// Search users by userName
|
95
|
+
// filter: userName eq "john@example.com"
|
96
|
+
const { data } = yield this.users.search(filter.split('eq ')[1].replace(/['"]+/g, ''), directoryId);
|
97
|
+
users = data;
|
98
|
+
totalResults = users ? users.length : 0;
|
99
|
+
}
|
100
|
+
else {
|
101
|
+
// Fetch all the existing Users (Paginated)
|
102
|
+
// At this moment, we don't have method to count the database records.
|
103
|
+
const { data: allUsers } = yield this.users.getAll({ directoryId });
|
104
|
+
const { data } = yield this.users.getAll({ pageOffset: startIndex - 1, pageLimit: count, directoryId });
|
105
|
+
users = data;
|
106
|
+
totalResults = allUsers ? allUsers.length : 0;
|
107
|
+
}
|
108
|
+
return {
|
109
|
+
status: 200,
|
110
|
+
data: {
|
111
|
+
schemas: ['urn:ietf:params:scim:api:messages:2.0:ListResponse'],
|
112
|
+
startIndex: startIndex ? startIndex : 1,
|
113
|
+
totalResults: totalResults ? totalResults : 0,
|
114
|
+
itemsPerPage: count ? count : 0,
|
115
|
+
Resources: users ? users.map((user) => user.raw) : [],
|
116
|
+
},
|
117
|
+
};
|
118
|
+
});
|
119
|
+
}
|
120
|
+
respondWithError(error) {
|
121
|
+
return {
|
122
|
+
status: error ? error.code : 500,
|
123
|
+
data: {
|
124
|
+
schemas: ['urn:ietf:params:scim:api:messages:2.0:Error'],
|
125
|
+
detail: error ? error.message : 'Internal Server Error',
|
126
|
+
},
|
127
|
+
};
|
128
|
+
}
|
129
|
+
// Handle the request from the Identity Provider and route it to the appropriate method
|
130
|
+
handleRequest(request, callback) {
|
131
|
+
return __awaiter(this, void 0, void 0, function* () {
|
132
|
+
const { body, query, resourceId: userId, directoryId, apiSecret } = request;
|
133
|
+
const method = request.method.toUpperCase();
|
134
|
+
// Get the directory
|
135
|
+
const { data: directory, error } = yield this.directories.get(directoryId);
|
136
|
+
if (error) {
|
137
|
+
return this.respondWithError(error);
|
138
|
+
}
|
139
|
+
if (!directory) {
|
140
|
+
return {
|
141
|
+
status: 200,
|
142
|
+
data: {},
|
143
|
+
};
|
144
|
+
}
|
145
|
+
if (!isConnectionActive(directory)) {
|
146
|
+
return {
|
147
|
+
status: 200,
|
148
|
+
data: {},
|
149
|
+
};
|
150
|
+
}
|
151
|
+
// Validate the request
|
152
|
+
if (directory.scim.secret != apiSecret) {
|
153
|
+
return this.respondWithError({ code: 401, message: 'Unauthorized' });
|
154
|
+
}
|
155
|
+
this.callback = callback;
|
156
|
+
this.users.setTenantAndProduct(directory.tenant, directory.product);
|
157
|
+
// Get the user
|
158
|
+
const { data: user } = userId ? yield this.users.get(userId) : { data: null };
|
159
|
+
// Delete password if exists in the body
|
160
|
+
if (body && 'password' in body) {
|
161
|
+
delete body['password'];
|
162
|
+
}
|
163
|
+
if (userId && !user) {
|
164
|
+
return this.respondWithError({ code: 404, message: 'User not found' });
|
165
|
+
}
|
166
|
+
if (user) {
|
167
|
+
switch (method) {
|
168
|
+
case 'GET':
|
169
|
+
return yield this.get(user);
|
170
|
+
case 'PATCH':
|
171
|
+
return yield this.patch(directory, user, body);
|
172
|
+
case 'PUT':
|
173
|
+
return yield this.update(directory, user, body);
|
174
|
+
case 'DELETE':
|
175
|
+
return yield this.delete(directory, user);
|
176
|
+
}
|
177
|
+
}
|
178
|
+
switch (method) {
|
179
|
+
case 'POST':
|
180
|
+
return yield this.create(directory, body);
|
181
|
+
case 'GET':
|
182
|
+
return yield this.getAll({
|
183
|
+
count: query.count,
|
184
|
+
startIndex: query.startIndex,
|
185
|
+
filter: query.filter,
|
186
|
+
directoryId,
|
187
|
+
});
|
188
|
+
}
|
189
|
+
return this.respondWithError({ code: 404, message: 'Not found' });
|
190
|
+
});
|
191
|
+
}
|
192
|
+
}
|
193
|
+
//# sourceMappingURL=DirectoryUsers.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"DirectoryUsers.js","sourceRoot":"","sources":["../../../../src/directory-sync/scim/DirectoryUsers.ts"],"names":[],"mappings":";;;;;;;;;AAWA,OAAO,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AACxG,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAOpC,MAAM,OAAO,cAAc;IAKzB,YAAY,EAAE,WAAW,EAAE,KAAK,EAAwB;QACtD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAEY,MAAM,CAAC,SAAoB,EAAE,IAAS;;YACjD,MAAM,cAAc,GAAG,6BAA6B,CAAC,IAAI,CAAC,CAAC;YAE3D,mCAAmC;YACnC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC;YAEpF,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,E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AE,gBAAgB,EAAE,CAAC,CAAC;YACzE,CAAC;YAED,IAAI,IAAI,EAAE,CAAC;gBACT,QAAQ,MAAM,EAAE,CAAC;oBACf,KAAK,KAAK;wBACR,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;oBAC9B,KAAK,OAAO;wBACV,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;oBACjD,KAAK,KAAK;wBACR,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;oBAClD,KAAK,QAAQ;wBACX,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;gBAC9C,CAAC;YACH,CAAC;YAED,QAAQ,MAAM,EAAE,CAAC;gBACf,KAAK,MAAM;oBACT,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;gBAC5C,KAAK,KAAK;oBACR,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC;wBACvB,KAAK,EAAE,KAAK,CAAC,KAAe;wBAC5B,UAAU,EAAE,KAAK,CAAC,UAAoB;wBACtC,MAAM,EAAE,KAAK,CAAC,MAAM;wBACpB,WAAW;qBACZ,CAAC,CAAC;YACP,CAAC;YAED,OAAO,IAAI,CAAC,gBAAgB,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;QACpE,CAAC;KAAA;CACF"}
|
@@ -0,0 +1,166 @@
|
|
1
|
+
import type { Group, DatabaseStore, PaginationParams, Response, GroupMembership } from '../../typings';
|
2
|
+
import { Base } from './Base';
|
3
|
+
interface CreateGroupParams {
|
4
|
+
directoryId: string;
|
5
|
+
name: string;
|
6
|
+
raw: any;
|
7
|
+
id?: string;
|
8
|
+
}
|
9
|
+
/**
|
10
|
+
* @swagger
|
11
|
+
* parameters:
|
12
|
+
* groupId:
|
13
|
+
* name: groupId
|
14
|
+
* description: Group ID
|
15
|
+
* in: path
|
16
|
+
* required: true
|
17
|
+
* type: string
|
18
|
+
* tenant:
|
19
|
+
* name: tenant
|
20
|
+
* description: Tenant (Optional if directoryId is provided)
|
21
|
+
* in: query
|
22
|
+
* required: false
|
23
|
+
* type: string
|
24
|
+
* product:
|
25
|
+
* name: product
|
26
|
+
* in: query
|
27
|
+
* description: Product (Optional if directoryId is provided)
|
28
|
+
* required: false
|
29
|
+
* type: string
|
30
|
+
* directoryId:
|
31
|
+
* name: directoryId
|
32
|
+
* description: Directory ID (Optional if tenant/product is provided)
|
33
|
+
* in: query
|
34
|
+
* required: false
|
35
|
+
* type: string
|
36
|
+
*/
|
37
|
+
/**
|
38
|
+
* @swagger
|
39
|
+
* definitions:
|
40
|
+
* Group:
|
41
|
+
* type: object
|
42
|
+
* properties:
|
43
|
+
* id:
|
44
|
+
* type: string
|
45
|
+
* description: Group ID
|
46
|
+
* name:
|
47
|
+
* type: string
|
48
|
+
* description: Group name
|
49
|
+
* raw:
|
50
|
+
* type: object
|
51
|
+
* description: Raw group attributes from the Identity Provider
|
52
|
+
*/
|
53
|
+
export declare class Groups extends Base {
|
54
|
+
constructor({ db }: {
|
55
|
+
db: DatabaseStore;
|
56
|
+
});
|
57
|
+
create(params: CreateGroupParams): Promise<Response<Group>>;
|
58
|
+
/**
|
59
|
+
* @swagger
|
60
|
+
* /api/v1/dsync/groups/{groupId}:
|
61
|
+
* get:
|
62
|
+
* summary: Get group by id from a directory
|
63
|
+
* parameters:
|
64
|
+
* - $ref: '#/parameters/tenant'
|
65
|
+
* - $ref: '#/parameters/product'
|
66
|
+
* - $ref: '#/parameters/directoryId'
|
67
|
+
* - $ref: '#/parameters/groupId'
|
68
|
+
* tags:
|
69
|
+
* - Directory Sync
|
70
|
+
* produces:
|
71
|
+
* - application/json
|
72
|
+
* responses:
|
73
|
+
* 200:
|
74
|
+
* description: Success
|
75
|
+
* schema:
|
76
|
+
* $ref: '#/definitions/Group'
|
77
|
+
*/
|
78
|
+
get(id: string): Promise<Response<Group>>;
|
79
|
+
update(id: string, param: {
|
80
|
+
name: string;
|
81
|
+
raw: any;
|
82
|
+
}): Promise<Response<Group>>;
|
83
|
+
delete(id: string): Promise<Response<null>>;
|
84
|
+
addUserToGroup(groupId: string, userId: string): Promise<void>;
|
85
|
+
removeUserFromGroup(groupId: string, userId: string): Promise<void>;
|
86
|
+
isUserInGroup(groupId: string, userId: string): Promise<boolean>;
|
87
|
+
search(displayName: string, directoryId: string): Promise<Response<Group[]>>;
|
88
|
+
/**
|
89
|
+
* @swagger
|
90
|
+
* /api/v1/dsync/groups:
|
91
|
+
* get:
|
92
|
+
* summary: Get groups from a directory
|
93
|
+
* parameters:
|
94
|
+
* - $ref: '#/parameters/tenant'
|
95
|
+
* - $ref: '#/parameters/product'
|
96
|
+
* - $ref: '#/parameters/directoryId'
|
97
|
+
* - $ref: '#/parameters/pageOffset'
|
98
|
+
* - $ref: '#/parameters/pageLimit'
|
99
|
+
* - $ref: '#/parameters/pageToken'
|
100
|
+
* tags:
|
101
|
+
* - Directory Sync
|
102
|
+
* produces:
|
103
|
+
* - application/json
|
104
|
+
* responses:
|
105
|
+
* 200:
|
106
|
+
* description: Success
|
107
|
+
* content:
|
108
|
+
* application/json:
|
109
|
+
* schema:
|
110
|
+
* type: object
|
111
|
+
* properties:
|
112
|
+
* data:
|
113
|
+
* type: array
|
114
|
+
* items:
|
115
|
+
* $ref: '#/definitions/Group'
|
116
|
+
* pageToken:
|
117
|
+
* type: string
|
118
|
+
* description: token for pagination
|
119
|
+
*/
|
120
|
+
getAll(params: PaginationParams & {
|
121
|
+
directoryId?: string;
|
122
|
+
}): Promise<Response<Group[]>>;
|
123
|
+
/**
|
124
|
+
* @swagger
|
125
|
+
* definitions:
|
126
|
+
* Member:
|
127
|
+
* type: object
|
128
|
+
* properties:
|
129
|
+
* user_id:
|
130
|
+
* type: string
|
131
|
+
* description: ID of the user
|
132
|
+
* /api/v1/dsync/groups/{groupId}/members:
|
133
|
+
* get:
|
134
|
+
* summary: Get list of members in a group
|
135
|
+
* parameters:
|
136
|
+
* - $ref: '#/parameters/tenant'
|
137
|
+
* - $ref: '#/parameters/product'
|
138
|
+
* - $ref: '#/parameters/groupId'
|
139
|
+
* - $ref: '#/parameters/directoryId'
|
140
|
+
* - $ref: '#/parameters/pageOffset'
|
141
|
+
* - $ref: '#/parameters/pageLimit'
|
142
|
+
* - $ref: '#/parameters/pageToken'
|
143
|
+
* tags:
|
144
|
+
* - Directory Sync
|
145
|
+
* produces:
|
146
|
+
* - application/json
|
147
|
+
* responses:
|
148
|
+
* 200:
|
149
|
+
* description: Success
|
150
|
+
* content:
|
151
|
+
* application/json:
|
152
|
+
* schema:
|
153
|
+
* type: object
|
154
|
+
* properties:
|
155
|
+
* data:
|
156
|
+
* type: array
|
157
|
+
* items:
|
158
|
+
* $ref: '#/definitions/Member'
|
159
|
+
*/
|
160
|
+
getGroupMembers(parmas: {
|
161
|
+
groupId: string;
|
162
|
+
} & PaginationParams): Promise<Response<Pick<GroupMembership, 'user_id'>[]>>;
|
163
|
+
deleteAll(directoryId: string): Promise<void>;
|
164
|
+
removeAllUsers(groupId: string): Promise<void>;
|
165
|
+
}
|
166
|
+
export {};
|