@mondaydotcomorg/monday-authorization 3.5.1-feat-shaime-support-entity-attributes-in-authorization-sdk-d2be13e → 3.5.1-fix-authorize-profile-picker-9fcaf6a
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/attributions-service.d.ts.map +1 -1
- package/dist/attributions-service.js +0 -1
- package/dist/authorization-attributes-service.d.ts +54 -0
- package/dist/authorization-attributes-service.d.ts.map +1 -0
- package/dist/authorization-attributes-service.js +186 -0
- package/dist/authorization-service.d.ts.map +1 -1
- package/dist/authorization-service.js +34 -7
- package/dist/constants/sns.d.ts +2 -12
- package/dist/constants/sns.d.ts.map +1 -1
- package/dist/constants/sns.js +2 -22
- package/dist/esm/attributions-service.d.ts.map +1 -1
- package/dist/esm/attributions-service.mjs +0 -1
- package/dist/esm/authorization-attributes-service.d.ts +54 -0
- package/dist/esm/authorization-attributes-service.d.ts.map +1 -0
- package/dist/esm/authorization-attributes-service.mjs +180 -0
- package/dist/esm/authorization-service.d.ts.map +1 -1
- package/dist/esm/authorization-service.mjs +34 -7
- package/dist/esm/constants/sns.d.ts +2 -12
- package/dist/esm/constants/sns.d.ts.map +1 -1
- package/dist/esm/constants/sns.mjs +3 -17
- package/dist/esm/index.d.ts +1 -9
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.mjs +1 -7
- package/dist/esm/roles-service.d.ts +1 -1
- package/dist/esm/roles-service.mjs +1 -1
- package/dist/esm/types/authorization-attributes-contracts.d.ts +4 -36
- package/dist/esm/types/authorization-attributes-contracts.d.ts.map +1 -1
- package/dist/esm/types/authorization-attributes-contracts.mjs +1 -6
- package/dist/index.d.ts +1 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -15
- package/dist/roles-service.d.ts +1 -1
- package/dist/roles-service.js +1 -1
- package/dist/types/authorization-attributes-contracts.d.ts +4 -36
- package/dist/types/authorization-attributes-contracts.d.ts.map +1 -1
- package/dist/types/authorization-attributes-contracts.js +0 -5
- package/package.json +1 -1
- package/src/attributions-service.ts +0 -4
- package/src/authorization-attributes-service.ts +234 -0
- package/src/authorization-service.ts +71 -11
- package/src/constants/sns.ts +2 -19
- package/src/index.ts +1 -18
- package/src/roles-service.ts +1 -1
- package/src/types/authorization-attributes-contracts.ts +3 -56
- package/dist/authorization-attributes-ms-service.d.ts +0 -67
- package/dist/authorization-attributes-ms-service.d.ts.map +0 -1
- package/dist/authorization-attributes-ms-service.js +0 -256
- package/dist/authorization-attributes-sns-service.d.ts +0 -85
- package/dist/authorization-attributes-sns-service.d.ts.map +0 -1
- package/dist/authorization-attributes-sns-service.js +0 -203
- package/dist/base-attribute-assignment.d.ts +0 -18
- package/dist/base-attribute-assignment.d.ts.map +0 -1
- package/dist/base-attribute-assignment.js +0 -43
- package/dist/entity-attribute-assignment.d.ts +0 -24
- package/dist/entity-attribute-assignment.d.ts.map +0 -1
- package/dist/entity-attribute-assignment.js +0 -36
- package/dist/entity-attributes-constants.d.ts +0 -7
- package/dist/entity-attributes-constants.d.ts.map +0 -1
- package/dist/entity-attributes-constants.js +0 -9
- package/dist/errors/argument-error.d.ts +0 -4
- package/dist/errors/argument-error.d.ts.map +0 -1
- package/dist/errors/argument-error.js +0 -11
- package/dist/esm/authorization-attributes-ms-service.d.ts +0 -67
- package/dist/esm/authorization-attributes-ms-service.d.ts.map +0 -1
- package/dist/esm/authorization-attributes-ms-service.mjs +0 -254
- package/dist/esm/authorization-attributes-sns-service.d.ts +0 -85
- package/dist/esm/authorization-attributes-sns-service.d.ts.map +0 -1
- package/dist/esm/authorization-attributes-sns-service.mjs +0 -197
- package/dist/esm/base-attribute-assignment.d.ts +0 -18
- package/dist/esm/base-attribute-assignment.d.ts.map +0 -1
- package/dist/esm/base-attribute-assignment.mjs +0 -41
- package/dist/esm/entity-attribute-assignment.d.ts +0 -24
- package/dist/esm/entity-attribute-assignment.d.ts.map +0 -1
- package/dist/esm/entity-attribute-assignment.mjs +0 -34
- package/dist/esm/entity-attributes-constants.d.ts +0 -7
- package/dist/esm/entity-attributes-constants.d.ts.map +0 -1
- package/dist/esm/entity-attributes-constants.mjs +0 -7
- package/dist/esm/errors/argument-error.d.ts +0 -4
- package/dist/esm/errors/argument-error.d.ts.map +0 -1
- package/dist/esm/errors/argument-error.mjs +0 -9
- package/dist/esm/resource-attribute-assignment.d.ts +0 -24
- package/dist/esm/resource-attribute-assignment.d.ts.map +0 -1
- package/dist/esm/resource-attribute-assignment.mjs +0 -34
- package/dist/esm/resource-attributes-constants.d.ts +0 -25
- package/dist/esm/resource-attributes-constants.d.ts.map +0 -1
- package/dist/esm/resource-attributes-constants.mjs +0 -25
- package/dist/esm/utils/path-utils.d.ts +0 -8
- package/dist/esm/utils/path-utils.d.ts.map +0 -1
- package/dist/esm/utils/path-utils.mjs +0 -15
- package/dist/esm/utils/validation.d.ts +0 -45
- package/dist/esm/utils/validation.d.ts.map +0 -1
- package/dist/esm/utils/validation.mjs +0 -75
- package/dist/resource-attribute-assignment.d.ts +0 -24
- package/dist/resource-attribute-assignment.d.ts.map +0 -1
- package/dist/resource-attribute-assignment.js +0 -36
- package/dist/resource-attributes-constants.d.ts +0 -25
- package/dist/resource-attributes-constants.d.ts.map +0 -1
- package/dist/resource-attributes-constants.js +0 -28
- package/dist/utils/path-utils.d.ts +0 -8
- package/dist/utils/path-utils.d.ts.map +0 -1
- package/dist/utils/path-utils.js +0 -17
- package/dist/utils/validation.d.ts +0 -45
- package/dist/utils/validation.d.ts.map +0 -1
- package/dist/utils/validation.js +0 -77
- package/src/authorization-attributes-ms-service.ts +0 -400
- package/src/authorization-attributes-sns-service.ts +0 -290
- package/src/base-attribute-assignment.ts +0 -55
- package/src/entity-attribute-assignment.ts +0 -35
- package/src/entity-attributes-constants.ts +0 -7
- package/src/errors/argument-error.ts +0 -7
- package/src/resource-attribute-assignment.ts +0 -43
- package/src/resource-attributes-constants.ts +0 -26
- package/src/utils/path-utils.ts +0 -13
- package/src/utils/validation.ts +0 -77
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import chunk from 'lodash/chunk.js';
|
|
2
|
+
import { Api } from '@mondaydotcomorg/trident-backend-api';
|
|
3
|
+
import { sendToSns, getTopicAttributes } from '@mondaydotcomorg/monday-sns';
|
|
4
|
+
import { HttpFetcherError } from '@mondaydotcomorg/monday-fetch-api';
|
|
5
|
+
import { logger } from './authorization-internal-service.mjs';
|
|
6
|
+
import { getAttributionsFromApi } from './attributions-service.mjs';
|
|
7
|
+
import { ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE, SNS_ARN_ENV_VAR_NAME, SNS_DEV_TEST_NAME, RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND } from './constants/sns.mjs';
|
|
8
|
+
import { ERROR_MESSAGES, DEFAULT_FETCH_OPTIONS, APP_NAME } from './constants.mjs';
|
|
9
|
+
|
|
10
|
+
class AuthorizationAttributesService {
|
|
11
|
+
static LOG_TAG = 'authorization_attributes';
|
|
12
|
+
static API_PATHS = {
|
|
13
|
+
UPSERT_RESOURCE_ATTRIBUTES: '/attributes/{accountId}/resource',
|
|
14
|
+
DELETE_RESOURCE_ATTRIBUTES: '/attributes/{accountId}/resource/{resourceType}/{resourceId}',
|
|
15
|
+
};
|
|
16
|
+
httpClient;
|
|
17
|
+
fetchOptions;
|
|
18
|
+
snsArn;
|
|
19
|
+
/**
|
|
20
|
+
* Public constructor to create the AuthorizationAttributesService instance.
|
|
21
|
+
* @param httpClient The HTTP client to use for API requests, if not provided, the default HTTP client from Api will be used.
|
|
22
|
+
* @param fetchOptions The fetch options to use for API requests, if not provided, the default fetch options will be used.
|
|
23
|
+
*/
|
|
24
|
+
constructor(httpClient, fetchOptions) {
|
|
25
|
+
if (!httpClient) {
|
|
26
|
+
httpClient = Api.getPart('httpClient');
|
|
27
|
+
if (!httpClient) {
|
|
28
|
+
throw new Error(ERROR_MESSAGES.HTTP_CLIENT_NOT_INITIALIZED);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (!fetchOptions) {
|
|
32
|
+
fetchOptions = DEFAULT_FETCH_OPTIONS;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
fetchOptions = {
|
|
36
|
+
...DEFAULT_FETCH_OPTIONS,
|
|
37
|
+
...fetchOptions,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
this.httpClient = httpClient;
|
|
41
|
+
this.fetchOptions = fetchOptions;
|
|
42
|
+
this.snsArn = AuthorizationAttributesService.getSnsTopicArn();
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Upsert resource attributes synchronously, performing http call to the authorization MS to assign the given attributes to the given resource.
|
|
46
|
+
* @param accountId
|
|
47
|
+
* @param resourceAttributeAssignments - Array of resource (resourceType, resourceId) and attribute (key, value) pairs to upsert in the authorization MS.
|
|
48
|
+
* e.g. [{ resourceType: 'board', resourceId: 123, key: 'board_kind', value: 'private' }]
|
|
49
|
+
* @returns ResourceAttributeResponse - The affected (created and updated_ resource attributes assignments in the `attributes` field.
|
|
50
|
+
*/
|
|
51
|
+
async upsertResourceAttributes(accountId, resourceAttributeAssignments) {
|
|
52
|
+
const attributionHeaders = getAttributionsFromApi();
|
|
53
|
+
try {
|
|
54
|
+
return await this.httpClient.fetch({
|
|
55
|
+
url: {
|
|
56
|
+
appName: APP_NAME,
|
|
57
|
+
path: AuthorizationAttributesService.API_PATHS.UPSERT_RESOURCE_ATTRIBUTES.replace('{accountId}', accountId.toString()),
|
|
58
|
+
},
|
|
59
|
+
method: 'POST',
|
|
60
|
+
headers: {
|
|
61
|
+
'Content-Type': 'application/json',
|
|
62
|
+
...attributionHeaders,
|
|
63
|
+
},
|
|
64
|
+
body: JSON.stringify({ resourceAttributeAssignments }),
|
|
65
|
+
}, this.fetchOptions);
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
if (err instanceof HttpFetcherError) {
|
|
69
|
+
throw new Error(ERROR_MESSAGES.REQUEST_FAILED('upsertResourceAttributes', err.status, err.message));
|
|
70
|
+
}
|
|
71
|
+
throw err;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Delete resource attributes assignments synchronously, performing http call to the authorization MS to delete the given attributes from the given singular resource.
|
|
76
|
+
* @param accountId
|
|
77
|
+
* @param resource - The resource (resourceType, resourceId) to delete the attributes for.
|
|
78
|
+
* @param attributeKeys - Array of attribute keys to delete for the resource.
|
|
79
|
+
* @returns ResourceAttributeResponse - The affected (deleted) resource attributes assignments in the `attributes` field.
|
|
80
|
+
*/
|
|
81
|
+
async deleteResourceAttributes(accountId, resource, attributeKeys) {
|
|
82
|
+
const attributionHeaders = getAttributionsFromApi();
|
|
83
|
+
if (!resource.id) {
|
|
84
|
+
throw new Error('Resource ID is required');
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
return await this.httpClient.fetch({
|
|
88
|
+
url: {
|
|
89
|
+
appName: APP_NAME,
|
|
90
|
+
path: AuthorizationAttributesService.API_PATHS.DELETE_RESOURCE_ATTRIBUTES.replace('{accountId}', accountId.toString())
|
|
91
|
+
.replace('{resourceType}', resource.type)
|
|
92
|
+
.replace('{resourceId}', resource.id.toString()),
|
|
93
|
+
},
|
|
94
|
+
method: 'DELETE',
|
|
95
|
+
headers: {
|
|
96
|
+
'Content-Type': 'application/json',
|
|
97
|
+
...attributionHeaders,
|
|
98
|
+
},
|
|
99
|
+
body: JSON.stringify({ keys: attributeKeys }),
|
|
100
|
+
}, this.fetchOptions);
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
if (err instanceof HttpFetcherError) {
|
|
104
|
+
throw new Error(ERROR_MESSAGES.REQUEST_FAILED('deleteResourceAttributes', err.status, err.message));
|
|
105
|
+
}
|
|
106
|
+
throw err;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Async function, this function only send the updates request to SNS and return before the change actually took place
|
|
111
|
+
* @param accountId
|
|
112
|
+
* @param appName - App name of the calling app
|
|
113
|
+
* @param callerActionIdentifier - action identifier
|
|
114
|
+
* @param resourceAttributeOperations - Array of operations to do on resource attributes.
|
|
115
|
+
* @return {Promise<ResourceAttributesOperation[]>} Array of sent operations
|
|
116
|
+
* */
|
|
117
|
+
async updateResourceAttributesAsync(accountId, appName, callerActionIdentifier, resourceAttributeOperations) {
|
|
118
|
+
const topicArn = this.snsArn;
|
|
119
|
+
const sendToSnsPromises = [];
|
|
120
|
+
const operationChucks = chunk(resourceAttributeOperations, ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE);
|
|
121
|
+
for (const operationsChunk of operationChucks) {
|
|
122
|
+
sendToSnsPromises.push(this.sendSingleSnsMessage(topicArn, accountId, appName, callerActionIdentifier, operationsChunk));
|
|
123
|
+
}
|
|
124
|
+
return (await Promise.all(sendToSnsPromises)).flat();
|
|
125
|
+
}
|
|
126
|
+
async sendSingleSnsMessage(topicArn, accountId, appName, callerActionIdentifier, operations) {
|
|
127
|
+
const payload = {
|
|
128
|
+
kind: RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND,
|
|
129
|
+
payload: {
|
|
130
|
+
accountId: accountId,
|
|
131
|
+
callerAppName: appName,
|
|
132
|
+
callerActionIdentifier: callerActionIdentifier,
|
|
133
|
+
operations: operations,
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
try {
|
|
137
|
+
await sendToSns(payload, topicArn);
|
|
138
|
+
return operations;
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
logger.error({ error, tag: AuthorizationAttributesService.LOG_TAG }, 'Authorization resource attributes async update: failed to send operations to SNS');
|
|
142
|
+
return [];
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
static getSnsTopicArn() {
|
|
146
|
+
const arnFromEnv = process.env[SNS_ARN_ENV_VAR_NAME];
|
|
147
|
+
if (arnFromEnv) {
|
|
148
|
+
return arnFromEnv;
|
|
149
|
+
}
|
|
150
|
+
if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {
|
|
151
|
+
return SNS_DEV_TEST_NAME;
|
|
152
|
+
}
|
|
153
|
+
throw new Error('Unable to get sns topic arn from env variable');
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Checks we can contact the required SNS topic that used to send attribute updates to Authorization MS.
|
|
157
|
+
* This function can be used as health check for services that updating resource attributes in async is crucial.
|
|
158
|
+
* Note this function only verify the POD can contact AWS SDK and the topic exists, but the user still might get
|
|
159
|
+
* errors when pushing for the SNS (e.g: in case the AWS role of the POD don't have permissions to push messages).
|
|
160
|
+
* However, this is the best we can do without actually push dummy messages to the SNS.
|
|
161
|
+
* @return {Promise<boolean>} - true if succeeded
|
|
162
|
+
*/
|
|
163
|
+
async asyncResourceAttributesHealthCheck() {
|
|
164
|
+
try {
|
|
165
|
+
const requestedTopicArn = this.snsArn;
|
|
166
|
+
const attributes = await getTopicAttributes(requestedTopicArn);
|
|
167
|
+
const isHealthy = !(!attributes || !('TopicArn' in attributes) || attributes.TopicArn !== requestedTopicArn);
|
|
168
|
+
if (!isHealthy) {
|
|
169
|
+
logger.error({ requestedTopicArn, snsReturnedAttributes: attributes, tag: AuthorizationAttributesService.LOG_TAG }, 'authorization-attributes-service failed in health check');
|
|
170
|
+
}
|
|
171
|
+
return isHealthy;
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
logger.error({ error, tag: AuthorizationAttributesService.LOG_TAG }, 'authorization-attributes-service got error during health check');
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export { AuthorizationAttributesService };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-service.d.ts","sourceRoot":"","sources":["../../src/authorization-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,EA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AAY,CAAC,EAAE,YAAY,CAAC;IAEnC;;;OAGG;WACU,YAAY,CACvB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,QAAQ,EAAE,EACrB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,iBAAiB,CAAC;WAEhB,YAAY,CACvB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,2BAA2B,EAAE,mBAAmB,EAAE,GACjD,OAAO,CAAC,iBAAiB,CAAC;IAY7B;;;OAGG;WACU,wBAAwB,CACnC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE;QAAE,eAAe,CAAC,EAAE,OAAO,CAAA;KAAO,GAC1C,OAAO,CAAC,OAAO,CAAC;mBAkBE,6BAA6B;IAclD,OAAO,CAAC,MAAM,CAAC,gBAAgB;WAIlB,gBAAgB,CAC3B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,kBAAkB,CAAC;IAM9B,OAAO,CAAC,MAAM,CAAC,UAAU;WA+DZ,wBAAwB,CACnC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,YAAY,EAAE,GAC5B,OAAO,CAAC,0BAA0B,EAAE,CAAC;mBA+DnB,oBAAoB;mBAUpB,oBAAoB;CAmF1C;AAED,wBAAgB,cAAc,CAC5B,MAAM,KAAA,EACN,sCAAsC,GAAE,MAAiD,QAY1F;AAED,wBAAsB,eAAe,kBAMpC;AAED,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,mBAAmB,CAepG"}
|
|
@@ -94,15 +94,33 @@ class AuthorizationService {
|
|
|
94
94
|
logger.error({ tag: 'authorization-service' }, 'AuthorizationService: igniteClient is not set, failing request');
|
|
95
95
|
throw new Error('AuthorizationService: igniteClient is not set, failing request');
|
|
96
96
|
}
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
const allowedProfiles = this.igniteClient.configuration.getObjectValue(ALLOWED_SDK_PLATFORM_PROFILES_KEY, []);
|
|
98
|
+
const isAllowedProfile = allowedProfiles.includes(appName);
|
|
99
|
+
logger.info({ tag: 'auth-debug', accountId, userId, appName, allowedProfiles, isAllowedProfile }, 'AuthorizationService.getProfile: checking allowed profiles');
|
|
100
|
+
if (isAllowedProfile) {
|
|
101
|
+
const profile = getProfile();
|
|
102
|
+
logger.info({ tag: 'auth-debug', accountId, userId, appName, profile }, 'AuthorizationService.getProfile: selected profile via allowed profiles');
|
|
103
|
+
return profile;
|
|
99
104
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
+
const inReleaseProfiles = this.igniteClient.configuration.getObjectValue(IN_RELEASE_SDK_PLATFORM_PROFILES_KEY, []);
|
|
106
|
+
const isInReleaseProfile = inReleaseProfiles.includes(appName);
|
|
107
|
+
const isFeatureFlagReleased = this.igniteClient.isReleased(PLATFORM_PROFILE_RELEASE_FF, { accountId, userId });
|
|
108
|
+
logger.info({
|
|
109
|
+
tag: 'auth-debug',
|
|
110
|
+
accountId,
|
|
111
|
+
userId,
|
|
112
|
+
appName,
|
|
113
|
+
inReleaseProfiles,
|
|
114
|
+
isInReleaseProfile,
|
|
115
|
+
isFeatureFlagReleased,
|
|
116
|
+
featureFlag: PLATFORM_PROFILE_RELEASE_FF,
|
|
117
|
+
}, 'AuthorizationService.getProfile: checking feature flag release');
|
|
118
|
+
if (isInReleaseProfile && isFeatureFlagReleased) {
|
|
119
|
+
const profile = getProfile();
|
|
120
|
+
logger.info({ tag: 'auth-debug', accountId, userId, appName, profile }, 'AuthorizationService.getProfile: selected profile via feature flag release');
|
|
121
|
+
return profile;
|
|
105
122
|
}
|
|
123
|
+
logger.info({ tag: 'auth-debug', accountId, userId, appName, profile: PlatformProfile.APP }, 'AuthorizationService.getProfile: selected default APP profile');
|
|
106
124
|
return PlatformProfile.APP;
|
|
107
125
|
}
|
|
108
126
|
static async canActionInScopeMultiple(accountId, userId, scopedActions) {
|
|
@@ -110,15 +128,24 @@ class AuthorizationService {
|
|
|
110
128
|
return [];
|
|
111
129
|
}
|
|
112
130
|
const shouldNavigateToGraph = Boolean(this.igniteClient?.isReleased(NAVIGATE_CAN_ACTION_IN_SCOPE_TO_GRAPH_FF, { accountId, userId }));
|
|
131
|
+
logger.info({
|
|
132
|
+
tag: 'auth-debug',
|
|
133
|
+
accountId,
|
|
134
|
+
userId,
|
|
135
|
+
shouldNavigateToGraph,
|
|
136
|
+
featureFlag: NAVIGATE_CAN_ACTION_IN_SCOPE_TO_GRAPH_FF,
|
|
137
|
+
}, 'AuthorizationService.canActionInScopeMultiple: determining which API flow to use');
|
|
113
138
|
const startTime = performance.now();
|
|
114
139
|
let scopedActionResponseObjects;
|
|
115
140
|
let apiType;
|
|
116
141
|
if (shouldNavigateToGraph) {
|
|
117
142
|
apiType = 'graph';
|
|
143
|
+
logger.info({ tag: 'auth-debug', accountId, userId, apiType }, 'AuthorizationService.canActionInScopeMultiple: using graph API flow');
|
|
118
144
|
scopedActionResponseObjects = await this.graphApi.checkPermissions(accountId, userId, scopedActions);
|
|
119
145
|
}
|
|
120
146
|
else {
|
|
121
147
|
apiType = 'platform';
|
|
148
|
+
logger.info({ tag: 'auth-debug', accountId, userId, apiType }, 'AuthorizationService.canActionInScopeMultiple: using platform API flow');
|
|
122
149
|
const profile = this.getProfile(accountId, userId);
|
|
123
150
|
const internalAuthToken = AuthorizationInternalService.generateInternalAuthToken(accountId, userId);
|
|
124
151
|
scopedActionResponseObjects = await this.platformApi.checkPermissions(profile, internalAuthToken, userId, scopedActions);
|
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
export declare enum SnsTopicType {
|
|
2
|
-
RESOURCE = "resource",
|
|
3
|
-
ENTITY = "entity"
|
|
4
|
-
}
|
|
5
|
-
export declare const RESOURCE_SNS_ARN_ENV_VAR_NAME = "SHARED_AUTHORIZATION_SNS_ENDPOINT_RESOURCE_ATTRIBUTES";
|
|
6
|
-
export declare const RESOURCE_SNS_DEV_TEST_NAME = "arn:aws:sns:us-east-1:000000000000:monday-authorization-resource-attributes-sns-local";
|
|
7
|
-
export declare const ENTITY_SNS_ARN_ENV_VAR_NAME = "SHARED_AUTHORIZATION_SNS_ENDPOINT_ENTITY_ATTRIBUTES";
|
|
8
|
-
export declare const ENTITY_SNS_DEV_TEST_NAME = "arn:aws:sns:us-east-1:000000000000:monday-authorization-entity-attributes-sns-local";
|
|
9
|
-
export declare const RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = "resourceAttributeModification";
|
|
10
|
-
export declare const ENTITY_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = "entityAttributeModification";
|
|
11
|
-
export declare const ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE = 100;
|
|
12
|
-
export declare const ASYNC_ENTITY_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE = 100;
|
|
13
1
|
export declare const SNS_ARN_ENV_VAR_NAME = "SHARED_AUTHORIZATION_SNS_ENDPOINT_RESOURCE_ATTRIBUTES";
|
|
14
2
|
export declare const SNS_DEV_TEST_NAME = "arn:aws:sns:us-east-1:000000000000:monday-authorization-resource-attributes-sns-local";
|
|
3
|
+
export declare const RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = "resourceAttributeModification";
|
|
4
|
+
export declare const ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE = 100;
|
|
15
5
|
//# sourceMappingURL=sns.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sns.d.ts","sourceRoot":"","sources":["../../../src/constants/sns.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"sns.d.ts","sourceRoot":"","sources":["../../../src/constants/sns.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,0DAA0D,CAAC;AAC5F,eAAO,MAAM,iBAAiB,0FAC2D,CAAC;AAC1F,eAAO,MAAM,qDAAqD,kCAAkC,CAAC;AACrG,eAAO,MAAM,oDAAoD,MAAM,CAAC"}
|
|
@@ -1,20 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
SnsTopicType["RESOURCE"] = "resource";
|
|
4
|
-
SnsTopicType["ENTITY"] = "entity";
|
|
5
|
-
})(SnsTopicType || (SnsTopicType = {}));
|
|
6
|
-
// Resource SNS constants
|
|
7
|
-
const RESOURCE_SNS_ARN_ENV_VAR_NAME = 'SHARED_AUTHORIZATION_SNS_ENDPOINT_RESOURCE_ATTRIBUTES';
|
|
8
|
-
const RESOURCE_SNS_DEV_TEST_NAME = 'arn:aws:sns:us-east-1:000000000000:monday-authorization-resource-attributes-sns-local';
|
|
9
|
-
// Entity SNS constants
|
|
10
|
-
const ENTITY_SNS_ARN_ENV_VAR_NAME = 'SHARED_AUTHORIZATION_SNS_ENDPOINT_ENTITY_ATTRIBUTES';
|
|
11
|
-
const ENTITY_SNS_DEV_TEST_NAME = 'arn:aws:sns:us-east-1:000000000000:monday-authorization-entity-attributes-sns-local';
|
|
1
|
+
const SNS_ARN_ENV_VAR_NAME = 'SHARED_AUTHORIZATION_SNS_ENDPOINT_RESOURCE_ATTRIBUTES';
|
|
2
|
+
const SNS_DEV_TEST_NAME = 'arn:aws:sns:us-east-1:000000000000:monday-authorization-resource-attributes-sns-local';
|
|
12
3
|
const RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = 'resourceAttributeModification';
|
|
13
|
-
const ENTITY_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND = 'entityAttributeModification';
|
|
14
4
|
const ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE = 100;
|
|
15
|
-
const ASYNC_ENTITY_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE = 100;
|
|
16
|
-
// Legacy exports for backward compatibility
|
|
17
|
-
const SNS_ARN_ENV_VAR_NAME = RESOURCE_SNS_ARN_ENV_VAR_NAME;
|
|
18
|
-
const SNS_DEV_TEST_NAME = RESOURCE_SNS_DEV_TEST_NAME;
|
|
19
5
|
|
|
20
|
-
export {
|
|
6
|
+
export { ASYNC_RESOURCE_ATTRIBUTES_MAX_OPERATIONS_PER_MESSAGE, RESOURCE_ATTRIBUTES_SNS_UPDATE_OPERATION_MESSAGE_KIND, SNS_ARN_ENV_VAR_NAME, SNS_DEV_TEST_NAME };
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -18,15 +18,7 @@ export interface InitOptions {
|
|
|
18
18
|
export declare function init(options?: InitOptions): Promise<void>;
|
|
19
19
|
export { authorizationCheckMiddleware, getAuthorizationMiddleware, skipAuthorizationMiddleware, } from './authorization-middleware';
|
|
20
20
|
export { AuthorizationService, AuthorizeResponse } from './authorization-service';
|
|
21
|
-
export {
|
|
22
|
-
export { AuthorizationAttributesMsService } from './authorization-attributes-ms-service';
|
|
23
|
-
export { ResourceAttributeAssignment } from './resource-attribute-assignment';
|
|
24
|
-
export { RESOURCE_TYPES, RESOURCE_ATTRIBUTES_CONSTANTS } from './resource-attributes-constants';
|
|
25
|
-
export { EntityAttributeAssignment } from './entity-attribute-assignment';
|
|
26
|
-
export { ENTITY_TYPES } from './entity-attributes-constants';
|
|
27
|
-
export { ArgumentError } from './errors/argument-error';
|
|
28
|
-
export { ResourceAttributeResponse, EntityAttributeResponse, ResourceType, EntityAttributeKeyType, ResourceAttributeKeyType, CommonAttributeKey, ResourceAttributeKey, EntityAttributeKey, } from './types/authorization-attributes-contracts';
|
|
29
|
-
export type { EntityType } from './entity-attributes-constants';
|
|
21
|
+
export { AuthorizationAttributesService } from './authorization-attributes-service';
|
|
30
22
|
export { RolesService } from './roles-service';
|
|
31
23
|
export { MembershipsService } from './memberships';
|
|
32
24
|
export { AuthorizationObject, Resource, BaseRequest, ResourceGetter, ContextGetter } from './types/general';
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,EAAqB,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,UAAU,kBAAkB;IAC1B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,sCAAsC,CAAC,EAAE,MAAM,CAAC;IAChD,OAAO,CAAC,EAAE,kBAAkB,CAAC;CAC9B;AAED,wBAAsB,IAAI,CAAC,OAAO,GAAE,WAAgB,iBA6BnD;AAED,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAClF,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,EAAqB,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,UAAU,kB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js';
|
|
6
6
|
export { testKit_index as TestKit };
|
|
7
7
|
export { authorizationCheckMiddleware, getAuthorizationMiddleware, skipAuthorizationMiddleware } from './authorization-middleware.mjs';
|
|
8
|
-
export {
|
|
9
|
-
export { AuthorizationAttributesMsService } from './authorization-attributes-ms-service.mjs';
|
|
10
|
-
export { ResourceAttributeAssignment } from './resource-attribute-assignment.mjs';
|
|
11
|
-
export { RESOURCE_ATTRIBUTES_CONSTANTS, RESOURCE_TYPES } from './resource-attributes-constants.mjs';
|
|
12
|
-
export { EntityAttributeAssignment } from './entity-attribute-assignment.mjs';
|
|
13
|
-
export { ENTITY_TYPES } from './entity-attributes-constants.mjs';
|
|
14
|
-
export { ArgumentError } from './errors/argument-error.mjs';
|
|
8
|
+
export { AuthorizationAttributesService } from './authorization-attributes-service.mjs';
|
|
15
9
|
export { RolesService } from './roles-service.mjs';
|
|
16
10
|
export { MembershipsService } from './memberships.mjs';
|
|
17
11
|
export { RoleType } from './types/roles.mjs';
|
|
@@ -6,7 +6,7 @@ export declare class RolesService {
|
|
|
6
6
|
private fetchOptions;
|
|
7
7
|
private attributionHeaders;
|
|
8
8
|
/**
|
|
9
|
-
* Public constructor to create the
|
|
9
|
+
* Public constructor to create the AuthorizationAttributesService instance.
|
|
10
10
|
* @param httpClient The HTTP client to use for API requests, if not provided, the default HTTP client from Api will be used.
|
|
11
11
|
* @param fetchOptions The fetch options to use for API requests, if not provided, the default fetch options will be used.
|
|
12
12
|
*/
|
|
@@ -9,7 +9,7 @@ class RolesService {
|
|
|
9
9
|
fetchOptions;
|
|
10
10
|
attributionHeaders;
|
|
11
11
|
/**
|
|
12
|
-
* Public constructor to create the
|
|
12
|
+
* Public constructor to create the AuthorizationAttributesService instance.
|
|
13
13
|
* @param httpClient The HTTP client to use for API requests, if not provided, the default HTTP client from Api will be used.
|
|
14
14
|
* @param fetchOptions The fetch options to use for API requests, if not provided, the default fetch options will be used.
|
|
15
15
|
*/
|
|
@@ -1,60 +1,28 @@
|
|
|
1
1
|
import { Resource } from './general';
|
|
2
|
-
import type { EntityType } from '../entity-attributes-constants';
|
|
3
|
-
import type { ResourceType } from '../resource-attributes-constants';
|
|
4
|
-
export type { EntityType, ResourceType };
|
|
5
|
-
export type CommonAttributeKey = string;
|
|
6
|
-
export type ResourceAttributeKey = string;
|
|
7
|
-
export type EntityAttributeKey = string;
|
|
8
|
-
export type ResourceAttributeKeyType = CommonAttributeKey | ResourceAttributeKey;
|
|
9
|
-
export type EntityAttributeKeyType = CommonAttributeKey | EntityAttributeKey;
|
|
10
2
|
export interface ResourceAttributeAssignment {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
key:
|
|
14
|
-
value: string;
|
|
15
|
-
}
|
|
16
|
-
export interface EntityAttributeAssignment {
|
|
17
|
-
entityId: number;
|
|
18
|
-
entityType: EntityType;
|
|
19
|
-
key: EntityAttributeKeyType;
|
|
3
|
+
resourceType: Resource['type'];
|
|
4
|
+
resourceId: Resource['id'];
|
|
5
|
+
key: string;
|
|
20
6
|
value: string;
|
|
21
7
|
}
|
|
22
8
|
export interface ResourceAttributeResponse {
|
|
23
9
|
attributes: ResourceAttributeAssignment[];
|
|
24
10
|
}
|
|
25
|
-
export interface EntityAttributeResponse {
|
|
26
|
-
attributes: EntityAttributeAssignment[];
|
|
27
|
-
}
|
|
28
11
|
export interface ResourceAttributeDelete {
|
|
29
12
|
resourceType: Resource['type'];
|
|
30
13
|
resourceId: Resource['id'];
|
|
31
14
|
key: string;
|
|
32
15
|
}
|
|
33
|
-
export interface EntityAttributeDelete {
|
|
34
|
-
entityType: EntityType;
|
|
35
|
-
entityId: number;
|
|
36
|
-
key: string;
|
|
37
|
-
}
|
|
38
16
|
export declare enum ResourceAttributeOperationEnum {
|
|
39
17
|
UPSERT = "upsert",
|
|
40
18
|
DELETE = "delete"
|
|
41
19
|
}
|
|
42
|
-
export declare enum EntityAttributeOperationEnum {
|
|
43
|
-
UPSERT = "upsert",
|
|
44
|
-
DELETE = "delete"
|
|
45
|
-
}
|
|
46
20
|
interface UpsertResourceAttributeOperation extends ResourceAttributeAssignment {
|
|
47
21
|
operationType: ResourceAttributeOperationEnum.UPSERT;
|
|
48
22
|
}
|
|
49
23
|
interface DeleteResourceAttributeOperation extends ResourceAttributeDelete {
|
|
50
24
|
operationType: ResourceAttributeOperationEnum.DELETE;
|
|
51
25
|
}
|
|
52
|
-
interface UpsertEntityAttributeOperation extends EntityAttributeAssignment {
|
|
53
|
-
operationType: EntityAttributeOperationEnum.UPSERT;
|
|
54
|
-
}
|
|
55
|
-
interface DeleteEntityAttributeOperation extends EntityAttributeDelete {
|
|
56
|
-
operationType: EntityAttributeOperationEnum.DELETE;
|
|
57
|
-
}
|
|
58
26
|
export type ResourceAttributesOperation = UpsertResourceAttributeOperation | DeleteResourceAttributeOperation;
|
|
59
|
-
export
|
|
27
|
+
export {};
|
|
60
28
|
//# sourceMappingURL=authorization-attributes-contracts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-attributes-contracts.d.ts","sourceRoot":"","sources":["../../../src/types/authorization-attributes-contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"authorization-attributes-contracts.d.ts","sourceRoot":"","sources":["../../../src/types/authorization-attributes-contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,MAAM,WAAW,2BAA2B;IAC1C,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC/B,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,yBAAyB;IACxC,UAAU,EAAE,2BAA2B,EAAE,CAAC;CAC3C;AAED,MAAM,WAAW,uBAAuB;IACtC,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC/B,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3B,GAAG,EAAE,MAAM,CAAC;CACb;AAED,oBAAY,8BAA8B;IACxC,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB;AAED,UAAU,gCAAiC,SAAQ,2BAA2B;IAC5E,aAAa,EAAE,8BAA8B,CAAC,MAAM,CAAC;CACtD;AAED,UAAU,gCAAiC,SAAQ,uBAAuB;IACxE,aAAa,EAAE,8BAA8B,CAAC,MAAM,CAAC;CACtD;AAED,MAAM,MAAM,2BAA2B,GAAG,gCAAgC,GAAG,gCAAgC,CAAC"}
|
|
@@ -3,10 +3,5 @@ var ResourceAttributeOperationEnum;
|
|
|
3
3
|
ResourceAttributeOperationEnum["UPSERT"] = "upsert";
|
|
4
4
|
ResourceAttributeOperationEnum["DELETE"] = "delete";
|
|
5
5
|
})(ResourceAttributeOperationEnum || (ResourceAttributeOperationEnum = {}));
|
|
6
|
-
var EntityAttributeOperationEnum;
|
|
7
|
-
(function (EntityAttributeOperationEnum) {
|
|
8
|
-
EntityAttributeOperationEnum["UPSERT"] = "upsert";
|
|
9
|
-
EntityAttributeOperationEnum["DELETE"] = "delete";
|
|
10
|
-
})(EntityAttributeOperationEnum || (EntityAttributeOperationEnum = {}));
|
|
11
6
|
|
|
12
|
-
export {
|
|
7
|
+
export { ResourceAttributeOperationEnum };
|
package/dist/index.d.ts
CHANGED
|
@@ -18,15 +18,7 @@ export interface InitOptions {
|
|
|
18
18
|
export declare function init(options?: InitOptions): Promise<void>;
|
|
19
19
|
export { authorizationCheckMiddleware, getAuthorizationMiddleware, skipAuthorizationMiddleware, } from './authorization-middleware';
|
|
20
20
|
export { AuthorizationService, AuthorizeResponse } from './authorization-service';
|
|
21
|
-
export {
|
|
22
|
-
export { AuthorizationAttributesMsService } from './authorization-attributes-ms-service';
|
|
23
|
-
export { ResourceAttributeAssignment } from './resource-attribute-assignment';
|
|
24
|
-
export { RESOURCE_TYPES, RESOURCE_ATTRIBUTES_CONSTANTS } from './resource-attributes-constants';
|
|
25
|
-
export { EntityAttributeAssignment } from './entity-attribute-assignment';
|
|
26
|
-
export { ENTITY_TYPES } from './entity-attributes-constants';
|
|
27
|
-
export { ArgumentError } from './errors/argument-error';
|
|
28
|
-
export { ResourceAttributeResponse, EntityAttributeResponse, ResourceType, EntityAttributeKeyType, ResourceAttributeKeyType, CommonAttributeKey, ResourceAttributeKey, EntityAttributeKey, } from './types/authorization-attributes-contracts';
|
|
29
|
-
export type { EntityType } from './entity-attributes-constants';
|
|
21
|
+
export { AuthorizationAttributesService } from './authorization-attributes-service';
|
|
30
22
|
export { RolesService } from './roles-service';
|
|
31
23
|
export { MembershipsService } from './memberships';
|
|
32
24
|
export { AuthorizationObject, Resource, BaseRequest, ResourceGetter, ContextGetter } from './types/general';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,EAAqB,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,UAAU,kBAAkB;IAC1B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,sCAAsC,CAAC,EAAE,MAAM,CAAC;IAChD,OAAO,CAAC,EAAE,kBAAkB,CAAC;CAC9B;AAED,wBAAsB,IAAI,CAAC,OAAO,G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QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC5G,OAAO,EACL,WAAW,EACX,YAAY,EACZ,0BAA0B,EAC1B,kBAAkB,GACnB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAErH,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,13 +5,7 @@ const authorizationService = require('./authorization-service.js');
|
|
|
5
5
|
const metricsService = require('./metrics-service.js');
|
|
6
6
|
const testKit_index = require('./testKit/index.js');
|
|
7
7
|
const authorizationMiddleware = require('./authorization-middleware.js');
|
|
8
|
-
const
|
|
9
|
-
const authorizationAttributesMsService = require('./authorization-attributes-ms-service.js');
|
|
10
|
-
const resourceAttributeAssignment = require('./resource-attribute-assignment.js');
|
|
11
|
-
const resourceAttributesConstants = require('./resource-attributes-constants.js');
|
|
12
|
-
const entityAttributeAssignment = require('./entity-attribute-assignment.js');
|
|
13
|
-
const entityAttributesConstants = require('./entity-attributes-constants.js');
|
|
14
|
-
const errors_argumentError = require('./errors/argument-error.js');
|
|
8
|
+
const authorizationAttributesService = require('./authorization-attributes-service.js');
|
|
15
9
|
const rolesService = require('./roles-service.js');
|
|
16
10
|
const memberships = require('./memberships.js');
|
|
17
11
|
const types_roles = require('./types/roles.js');
|
|
@@ -49,14 +43,7 @@ exports.TestKit = testKit_index;
|
|
|
49
43
|
exports.authorizationCheckMiddleware = authorizationMiddleware.authorizationCheckMiddleware;
|
|
50
44
|
exports.getAuthorizationMiddleware = authorizationMiddleware.getAuthorizationMiddleware;
|
|
51
45
|
exports.skipAuthorizationMiddleware = authorizationMiddleware.skipAuthorizationMiddleware;
|
|
52
|
-
exports.
|
|
53
|
-
exports.AuthorizationAttributesMsService = authorizationAttributesMsService.AuthorizationAttributesMsService;
|
|
54
|
-
exports.ResourceAttributeAssignment = resourceAttributeAssignment.ResourceAttributeAssignment;
|
|
55
|
-
exports.RESOURCE_ATTRIBUTES_CONSTANTS = resourceAttributesConstants.RESOURCE_ATTRIBUTES_CONSTANTS;
|
|
56
|
-
exports.RESOURCE_TYPES = resourceAttributesConstants.RESOURCE_TYPES;
|
|
57
|
-
exports.EntityAttributeAssignment = entityAttributeAssignment.EntityAttributeAssignment;
|
|
58
|
-
exports.ENTITY_TYPES = entityAttributesConstants.ENTITY_TYPES;
|
|
59
|
-
exports.ArgumentError = errors_argumentError.ArgumentError;
|
|
46
|
+
exports.AuthorizationAttributesService = authorizationAttributesService.AuthorizationAttributesService;
|
|
60
47
|
exports.RolesService = rolesService.RolesService;
|
|
61
48
|
exports.MembershipsService = memberships.MembershipsService;
|
|
62
49
|
Object.defineProperty(exports, 'RoleType', {
|
package/dist/roles-service.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare class RolesService {
|
|
|
6
6
|
private fetchOptions;
|
|
7
7
|
private attributionHeaders;
|
|
8
8
|
/**
|
|
9
|
-
* Public constructor to create the
|
|
9
|
+
* Public constructor to create the AuthorizationAttributesService instance.
|
|
10
10
|
* @param httpClient The HTTP client to use for API requests, if not provided, the default HTTP client from Api will be used.
|
|
11
11
|
* @param fetchOptions The fetch options to use for API requests, if not provided, the default fetch options will be used.
|
|
12
12
|
*/
|
package/dist/roles-service.js
CHANGED
|
@@ -11,7 +11,7 @@ class RolesService {
|
|
|
11
11
|
fetchOptions;
|
|
12
12
|
attributionHeaders;
|
|
13
13
|
/**
|
|
14
|
-
* Public constructor to create the
|
|
14
|
+
* Public constructor to create the AuthorizationAttributesService instance.
|
|
15
15
|
* @param httpClient The HTTP client to use for API requests, if not provided, the default HTTP client from Api will be used.
|
|
16
16
|
* @param fetchOptions The fetch options to use for API requests, if not provided, the default fetch options will be used.
|
|
17
17
|
*/
|
|
@@ -1,60 +1,28 @@
|
|
|
1
1
|
import { Resource } from './general';
|
|
2
|
-
import type { EntityType } from '../entity-attributes-constants';
|
|
3
|
-
import type { ResourceType } from '../resource-attributes-constants';
|
|
4
|
-
export type { EntityType, ResourceType };
|
|
5
|
-
export type CommonAttributeKey = string;
|
|
6
|
-
export type ResourceAttributeKey = string;
|
|
7
|
-
export type EntityAttributeKey = string;
|
|
8
|
-
export type ResourceAttributeKeyType = CommonAttributeKey | ResourceAttributeKey;
|
|
9
|
-
export type EntityAttributeKeyType = CommonAttributeKey | EntityAttributeKey;
|
|
10
2
|
export interface ResourceAttributeAssignment {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
key:
|
|
14
|
-
value: string;
|
|
15
|
-
}
|
|
16
|
-
export interface EntityAttributeAssignment {
|
|
17
|
-
entityId: number;
|
|
18
|
-
entityType: EntityType;
|
|
19
|
-
key: EntityAttributeKeyType;
|
|
3
|
+
resourceType: Resource['type'];
|
|
4
|
+
resourceId: Resource['id'];
|
|
5
|
+
key: string;
|
|
20
6
|
value: string;
|
|
21
7
|
}
|
|
22
8
|
export interface ResourceAttributeResponse {
|
|
23
9
|
attributes: ResourceAttributeAssignment[];
|
|
24
10
|
}
|
|
25
|
-
export interface EntityAttributeResponse {
|
|
26
|
-
attributes: EntityAttributeAssignment[];
|
|
27
|
-
}
|
|
28
11
|
export interface ResourceAttributeDelete {
|
|
29
12
|
resourceType: Resource['type'];
|
|
30
13
|
resourceId: Resource['id'];
|
|
31
14
|
key: string;
|
|
32
15
|
}
|
|
33
|
-
export interface EntityAttributeDelete {
|
|
34
|
-
entityType: EntityType;
|
|
35
|
-
entityId: number;
|
|
36
|
-
key: string;
|
|
37
|
-
}
|
|
38
16
|
export declare enum ResourceAttributeOperationEnum {
|
|
39
17
|
UPSERT = "upsert",
|
|
40
18
|
DELETE = "delete"
|
|
41
19
|
}
|
|
42
|
-
export declare enum EntityAttributeOperationEnum {
|
|
43
|
-
UPSERT = "upsert",
|
|
44
|
-
DELETE = "delete"
|
|
45
|
-
}
|
|
46
20
|
interface UpsertResourceAttributeOperation extends ResourceAttributeAssignment {
|
|
47
21
|
operationType: ResourceAttributeOperationEnum.UPSERT;
|
|
48
22
|
}
|
|
49
23
|
interface DeleteResourceAttributeOperation extends ResourceAttributeDelete {
|
|
50
24
|
operationType: ResourceAttributeOperationEnum.DELETE;
|
|
51
25
|
}
|
|
52
|
-
interface UpsertEntityAttributeOperation extends EntityAttributeAssignment {
|
|
53
|
-
operationType: EntityAttributeOperationEnum.UPSERT;
|
|
54
|
-
}
|
|
55
|
-
interface DeleteEntityAttributeOperation extends EntityAttributeDelete {
|
|
56
|
-
operationType: EntityAttributeOperationEnum.DELETE;
|
|
57
|
-
}
|
|
58
26
|
export type ResourceAttributesOperation = UpsertResourceAttributeOperation | DeleteResourceAttributeOperation;
|
|
59
|
-
export
|
|
27
|
+
export {};
|
|
60
28
|
//# sourceMappingURL=authorization-attributes-contracts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-attributes-contracts.d.ts","sourceRoot":"","sources":["../../src/types/authorization-attributes-contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"authorization-attributes-contracts.d.ts","sourceRoot":"","sources":["../../src/types/authorization-attributes-contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,MAAM,WAAW,2BAA2B;IAC1C,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC/B,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,yBAAyB;IACxC,UAAU,EAAE,2BAA2B,EAAE,CAAC;CAC3C;AAED,MAAM,WAAW,uBAAuB;IACtC,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC/B,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3B,GAAG,EAAE,MAAM,CAAC;CACb;AAED,oBAAY,8BAA8B;IACxC,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB;AAED,UAAU,gCAAiC,SAAQ,2BAA2B;IAC5E,aAAa,EAAE,8BAA8B,CAAC,MAAM,CAAC;CACtD;AAED,UAAU,gCAAiC,SAAQ,uBAAuB;IACxE,aAAa,EAAE,8BAA8B,CAAC,MAAM,CAAC;CACtD;AAED,MAAM,MAAM,2BAA2B,GAAG,gCAAgC,GAAG,gCAAgC,CAAC"}
|
|
@@ -5,8 +5,3 @@ exports.ResourceAttributeOperationEnum = void 0;
|
|
|
5
5
|
ResourceAttributeOperationEnum["UPSERT"] = "upsert";
|
|
6
6
|
ResourceAttributeOperationEnum["DELETE"] = "delete";
|
|
7
7
|
})(exports.ResourceAttributeOperationEnum || (exports.ResourceAttributeOperationEnum = {}));
|
|
8
|
-
exports.EntityAttributeOperationEnum = void 0;
|
|
9
|
-
(function (EntityAttributeOperationEnum) {
|
|
10
|
-
EntityAttributeOperationEnum["UPSERT"] = "upsert";
|
|
11
|
-
EntityAttributeOperationEnum["DELETE"] = "delete";
|
|
12
|
-
})(exports.EntityAttributeOperationEnum || (exports.EntityAttributeOperationEnum = {}));
|