@mondaydotcomorg/monday-authorization 3.5.1-debug-getprofile-not-resolving-to-internal-9f5fe0f → 3.5.1-debug-getprofile-not-resolving-to-internal-d02966c
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/authorization-service.d.ts.map +1 -1
- package/dist/authorization-service.js +58 -22
- package/dist/clients/graph-api.d.ts +5 -1
- package/dist/clients/graph-api.d.ts.map +1 -1
- package/dist/clients/graph-api.js +4 -2
- package/dist/esm/authorization-service.d.ts.map +1 -1
- package/dist/esm/authorization-service.mjs +58 -22
- package/dist/esm/clients/graph-api.d.ts +5 -1
- package/dist/esm/clients/graph-api.d.ts.map +1 -1
- package/dist/esm/clients/graph-api.mjs +4 -2
- package/package.json +1 -1
- package/src/authorization-service.ts +84 -28
- package/src/clients/graph-api.ts +5 -3
|
@@ -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,EAAmB,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG7F,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,0BAA0B,EAC1B,YAAY,EACb,MAAM,kCAAkC,CAAC;AAe1C,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,mBAAmB,CAAC,EAAE,mBAAmB,EAAE,CAAC;CAC7C;AAED,wBAAgB,sBAAsB,CAAC,wBAAwB,EAAE,kBAAkB,QAElF;AAMD,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,MAAM,KAAK,QAAQ,GAK1B;IACD,OAAO,CAAC,MAA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;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;WAwCZ,wBAAwB,CACnC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,YAAY,EAAE,GAC5B,OAAO,CAAC,0BAA0B,EAAE,CAAC;mBAwGnB,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"}
|
|
@@ -17,7 +17,6 @@ const PLATFORM_AUTHORIZE_PATH = '/internal_ms/authorization/authorize';
|
|
|
17
17
|
const ALLOWED_SDK_PLATFORM_PROFILES_KEY = 'allowed-sdk-platform-profiles';
|
|
18
18
|
const IN_RELEASE_SDK_PLATFORM_PROFILES_KEY = 'in-release-sdk-platform-profile';
|
|
19
19
|
const PLATFORM_PROFILE_RELEASE_FF = 'sdk-platform-profiles';
|
|
20
|
-
const NAVIGATE_CAN_ACTION_IN_SCOPE_TO_GRAPH_FF = 'navigate-can-action-in-scope-to-graph';
|
|
21
20
|
function setRequestFetchOptions(customMondayFetchOptions) {
|
|
22
21
|
authorizationInternalService.AuthorizationInternalService.setRequestFetchOptions(customMondayFetchOptions);
|
|
23
22
|
}
|
|
@@ -111,21 +110,17 @@ class AuthorizationService {
|
|
|
111
110
|
accountId,
|
|
112
111
|
userId,
|
|
113
112
|
};
|
|
114
|
-
console.log('[AuthorizationService.getProfile] Debug info:', debugInfo);
|
|
115
113
|
authorizationInternalService.logger.info({ tag: 'authorization-service', ...debugInfo }, 'AuthorizationService.getProfile debug info');
|
|
116
114
|
if (isInAllowedApps) {
|
|
117
115
|
const profile = attributionsService.getProfile();
|
|
118
|
-
console.log('[AuthorizationService.getProfile] Returning profile from ALLOWED_SDK_PLATFORM_PROFILES_KEY:', profile);
|
|
119
116
|
authorizationInternalService.logger.info({ tag: 'authorization-service', profile }, 'Returning profile from ALLOWED_SDK_PLATFORM_PROFILES_KEY');
|
|
120
117
|
return profile;
|
|
121
118
|
}
|
|
122
119
|
if (isInReleaseApps && isFeatureFlagReleased) {
|
|
123
120
|
const profile = attributionsService.getProfile();
|
|
124
|
-
console.log('[AuthorizationService.getProfile] Returning profile from IN_RELEASE_SDK_PLATFORM_PROFILES_KEY:', profile);
|
|
125
121
|
authorizationInternalService.logger.info({ tag: 'authorization-service', profile }, 'Returning profile from IN_RELEASE_SDK_PLATFORM_PROFILES_KEY');
|
|
126
122
|
return profile;
|
|
127
123
|
}
|
|
128
|
-
console.log('[AuthorizationService.getProfile] Returning default PlatformProfile.APP');
|
|
129
124
|
authorizationInternalService.logger.info({ tag: 'authorization-service', profile: attributionsService.PlatformProfile.APP }, 'Returning default PlatformProfile.APP');
|
|
130
125
|
return attributionsService.PlatformProfile.APP;
|
|
131
126
|
}
|
|
@@ -133,31 +128,72 @@ class AuthorizationService {
|
|
|
133
128
|
if (scopedActions.length === 0) {
|
|
134
129
|
return [];
|
|
135
130
|
}
|
|
136
|
-
const shouldNavigateToGraph = Boolean(this.igniteClient?.isReleased(NAVIGATE_CAN_ACTION_IN_SCOPE_TO_GRAPH_FF, { accountId, userId }));
|
|
137
131
|
const startTime = perf_hooks.performance.now();
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
const profile = this.getProfile(accountId, userId);
|
|
147
|
-
const internalAuthToken = authorizationInternalService.AuthorizationInternalService.generateInternalAuthToken(accountId, userId);
|
|
148
|
-
scopedActionResponseObjects = await this.platformApi.checkPermissions(profile, internalAuthToken, userId, scopedActions);
|
|
149
|
-
}
|
|
132
|
+
// Always call both APIs for comparison
|
|
133
|
+
const graphApiPromise = this.graphApi.checkPermissions(accountId, userId, scopedActions);
|
|
134
|
+
const profile = this.getProfile(accountId, userId);
|
|
135
|
+
const internalAuthToken = authorizationInternalService.AuthorizationInternalService.generateInternalAuthToken(accountId, userId);
|
|
136
|
+
const platformApiPromise = this.platformApi.checkPermissions(profile, internalAuthToken, userId, scopedActions);
|
|
137
|
+
const [graphApiResult, platformApiResponse] = await Promise.all([graphApiPromise, platformApiPromise]);
|
|
138
|
+
const graphApiResponse = graphApiResult.mapped;
|
|
139
|
+
const graphApiRawResponse = graphApiResult.raw;
|
|
150
140
|
const endTime = perf_hooks.performance.now();
|
|
151
141
|
const time = endTime - startTime;
|
|
152
|
-
//
|
|
153
|
-
|
|
142
|
+
// Compare responses and log differences with raw lookup values
|
|
143
|
+
const differences = [];
|
|
144
|
+
for (let i = 0; i < scopedActions.length; i++) {
|
|
145
|
+
const graphResult = graphApiResponse[i];
|
|
146
|
+
const platformResult = platformApiResponse[i];
|
|
147
|
+
const { action, scope } = scopedActions[i];
|
|
148
|
+
const { resourceType, resourceId } = utils_authorization_utils.scopeToResource(scope);
|
|
149
|
+
const graphCan = graphResult?.permit?.can;
|
|
150
|
+
const platformCan = platformResult?.permit?.can;
|
|
151
|
+
// Log the raw lookup values for debugging
|
|
152
|
+
const graphResponseAtPath = graphApiRawResponse?.[resourceType]?.[String(resourceId)]?.[action];
|
|
153
|
+
authorizationInternalService.logger.info({
|
|
154
|
+
tag: 'authorization-service-api-comparison-detail',
|
|
155
|
+
action,
|
|
156
|
+
scope,
|
|
157
|
+
resourceType,
|
|
158
|
+
resourceId,
|
|
159
|
+
graphResponseAtPath,
|
|
160
|
+
graphCan,
|
|
161
|
+
platformCan,
|
|
162
|
+
}, `API comparison detail for ${action} on ${resourceType}/${resourceId}`);
|
|
163
|
+
if (graphCan !== platformCan) {
|
|
164
|
+
differences.push({
|
|
165
|
+
action,
|
|
166
|
+
scope,
|
|
167
|
+
resourceType,
|
|
168
|
+
resourceId,
|
|
169
|
+
graphResponseAtPath,
|
|
170
|
+
graphCan,
|
|
171
|
+
platformCan,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
const isSame = differences.length === 0;
|
|
176
|
+
authorizationInternalService.logger.info({
|
|
177
|
+
tag: 'authorization-service-api-comparison',
|
|
178
|
+
accountId,
|
|
179
|
+
userId,
|
|
180
|
+
profile,
|
|
181
|
+
scopedActionsCount: scopedActions.length,
|
|
182
|
+
isSame,
|
|
183
|
+
differencesCount: differences.length,
|
|
184
|
+
differences: differences.length > 0 ? differences : undefined,
|
|
185
|
+
timeMs: time,
|
|
186
|
+
}, `API comparison: graphApi vs platformApi - ${isSame ? 'SAME' : 'DIFFERENT'}`);
|
|
187
|
+
// Record metrics for each authorization check (using platform response)
|
|
188
|
+
for (const obj of platformApiResponse) {
|
|
154
189
|
const { action, scope } = obj.scopedAction;
|
|
155
190
|
const { resourceType } = utils_authorization_utils.scopeToResource(scope);
|
|
156
191
|
const isAuthorized = obj.permit.can;
|
|
157
192
|
prometheusService.sendAuthorizationCheckResponseTimeMetric(resourceType, action, isAuthorized, 200, time);
|
|
158
|
-
metricsService.recordAuthorizationTiming(
|
|
193
|
+
metricsService.recordAuthorizationTiming('platform', time, 'canActionInScopeMultiple');
|
|
159
194
|
}
|
|
160
|
-
|
|
195
|
+
// Return platform API response
|
|
196
|
+
return platformApiResponse;
|
|
161
197
|
}
|
|
162
198
|
static async isAuthorizedSingular(accountId, userId, resources, action) {
|
|
163
199
|
const { authorizationObjects } = createAuthorizationParams(resources, action);
|
|
@@ -21,8 +21,12 @@ export declare class GraphApi {
|
|
|
21
21
|
private static mapResponse;
|
|
22
22
|
/**
|
|
23
23
|
* Performs a complete authorization check using the Graph API
|
|
24
|
+
* Returns both the mapped response and raw response for debugging
|
|
24
25
|
*/
|
|
25
|
-
checkPermissions(accountId: number, userId: number, scopedActions: ScopedAction[]): Promise<
|
|
26
|
+
checkPermissions(accountId: number, userId: number, scopedActions: ScopedAction[]): Promise<{
|
|
27
|
+
mapped: ScopedActionResponseObject[];
|
|
28
|
+
raw: GraphIsAllowedResponse;
|
|
29
|
+
}>;
|
|
26
30
|
private static ensureGraphReason;
|
|
27
31
|
}
|
|
28
32
|
//# sourceMappingURL=graph-api.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-api.d.ts","sourceRoot":"","sources":["../../src/clients/graph-api.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,YAAY,EACZ,0BAA0B,EAG3B,MAAM,mCAAmC,CAAC;AAG3C,OAAO,EAEL,sBAAsB,EAMvB,MAAM,0BAA0B,CAAC;AAQlC;;GAEG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IACxC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;;IAezC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAyB/B;;OAEG;IACG,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAiCzG;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IAiC1B
|
|
1
|
+
{"version":3,"file":"graph-api.d.ts","sourceRoot":"","sources":["../../src/clients/graph-api.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,YAAY,EACZ,0BAA0B,EAG3B,MAAM,mCAAmC,CAAC;AAG3C,OAAO,EAEL,sBAAsB,EAMvB,MAAM,0BAA0B,CAAC;AAQlC;;GAEG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IACxC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;;IAezC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAyB/B;;OAEG;IACG,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAiCzG;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IAiC1B;;;OAGG;IACG,gBAAgB,CACpB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,YAAY,EAAE,GAC5B,OAAO,CAAC;QAAE,MAAM,EAAE,0BAA0B,EAAE,CAAC;QAAC,GAAG,EAAE,sBAAsB,CAAA;KAAE,CAAC;IAOjF,OAAO,CAAC,MAAM,CAAC,iBAAiB;CAWjC"}
|
|
@@ -115,11 +115,13 @@ class GraphApi {
|
|
|
115
115
|
}
|
|
116
116
|
/**
|
|
117
117
|
* Performs a complete authorization check using the Graph API
|
|
118
|
+
* Returns both the mapped response and raw response for debugging
|
|
118
119
|
*/
|
|
119
120
|
async checkPermissions(accountId, userId, scopedActions) {
|
|
120
121
|
const authToken = mondayJwt.signAuthorizationHeader({ appName: this.consumerAppName, accountId, userId });
|
|
121
|
-
const
|
|
122
|
-
|
|
122
|
+
const rawResponse = await this.fetchPermissions(authToken, scopedActions);
|
|
123
|
+
const mappedResponse = GraphApi.mapResponse(scopedActions, rawResponse);
|
|
124
|
+
return { mapped: mappedResponse, raw: rawResponse };
|
|
123
125
|
}
|
|
124
126
|
static ensureGraphReason(reason, context) {
|
|
125
127
|
if (!reason || typeof reason !== 'object' || typeof reason.key !== 'string') {
|
|
@@ -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,EAAmB,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,QA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AM,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;WAwCZ,wBAAwB,CACnC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,YAAY,EAAE,GAC5B,OAAO,CAAC,0BAA0B,EAAE,CAAC;mBAwGnB,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"}
|
|
@@ -15,7 +15,6 @@ const PLATFORM_AUTHORIZE_PATH = '/internal_ms/authorization/authorize';
|
|
|
15
15
|
const ALLOWED_SDK_PLATFORM_PROFILES_KEY = 'allowed-sdk-platform-profiles';
|
|
16
16
|
const IN_RELEASE_SDK_PLATFORM_PROFILES_KEY = 'in-release-sdk-platform-profile';
|
|
17
17
|
const PLATFORM_PROFILE_RELEASE_FF = 'sdk-platform-profiles';
|
|
18
|
-
const NAVIGATE_CAN_ACTION_IN_SCOPE_TO_GRAPH_FF = 'navigate-can-action-in-scope-to-graph';
|
|
19
18
|
function setRequestFetchOptions(customMondayFetchOptions) {
|
|
20
19
|
AuthorizationInternalService.setRequestFetchOptions(customMondayFetchOptions);
|
|
21
20
|
}
|
|
@@ -109,21 +108,17 @@ class AuthorizationService {
|
|
|
109
108
|
accountId,
|
|
110
109
|
userId,
|
|
111
110
|
};
|
|
112
|
-
console.log('[AuthorizationService.getProfile] Debug info:', debugInfo);
|
|
113
111
|
logger.info({ tag: 'authorization-service', ...debugInfo }, 'AuthorizationService.getProfile debug info');
|
|
114
112
|
if (isInAllowedApps) {
|
|
115
113
|
const profile = getProfile();
|
|
116
|
-
console.log('[AuthorizationService.getProfile] Returning profile from ALLOWED_SDK_PLATFORM_PROFILES_KEY:', profile);
|
|
117
114
|
logger.info({ tag: 'authorization-service', profile }, 'Returning profile from ALLOWED_SDK_PLATFORM_PROFILES_KEY');
|
|
118
115
|
return profile;
|
|
119
116
|
}
|
|
120
117
|
if (isInReleaseApps && isFeatureFlagReleased) {
|
|
121
118
|
const profile = getProfile();
|
|
122
|
-
console.log('[AuthorizationService.getProfile] Returning profile from IN_RELEASE_SDK_PLATFORM_PROFILES_KEY:', profile);
|
|
123
119
|
logger.info({ tag: 'authorization-service', profile }, 'Returning profile from IN_RELEASE_SDK_PLATFORM_PROFILES_KEY');
|
|
124
120
|
return profile;
|
|
125
121
|
}
|
|
126
|
-
console.log('[AuthorizationService.getProfile] Returning default PlatformProfile.APP');
|
|
127
122
|
logger.info({ tag: 'authorization-service', profile: PlatformProfile.APP }, 'Returning default PlatformProfile.APP');
|
|
128
123
|
return PlatformProfile.APP;
|
|
129
124
|
}
|
|
@@ -131,31 +126,72 @@ class AuthorizationService {
|
|
|
131
126
|
if (scopedActions.length === 0) {
|
|
132
127
|
return [];
|
|
133
128
|
}
|
|
134
|
-
const shouldNavigateToGraph = Boolean(this.igniteClient?.isReleased(NAVIGATE_CAN_ACTION_IN_SCOPE_TO_GRAPH_FF, { accountId, userId }));
|
|
135
129
|
const startTime = performance.now();
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
const profile = this.getProfile(accountId, userId);
|
|
145
|
-
const internalAuthToken = AuthorizationInternalService.generateInternalAuthToken(accountId, userId);
|
|
146
|
-
scopedActionResponseObjects = await this.platformApi.checkPermissions(profile, internalAuthToken, userId, scopedActions);
|
|
147
|
-
}
|
|
130
|
+
// Always call both APIs for comparison
|
|
131
|
+
const graphApiPromise = this.graphApi.checkPermissions(accountId, userId, scopedActions);
|
|
132
|
+
const profile = this.getProfile(accountId, userId);
|
|
133
|
+
const internalAuthToken = AuthorizationInternalService.generateInternalAuthToken(accountId, userId);
|
|
134
|
+
const platformApiPromise = this.platformApi.checkPermissions(profile, internalAuthToken, userId, scopedActions);
|
|
135
|
+
const [graphApiResult, platformApiResponse] = await Promise.all([graphApiPromise, platformApiPromise]);
|
|
136
|
+
const graphApiResponse = graphApiResult.mapped;
|
|
137
|
+
const graphApiRawResponse = graphApiResult.raw;
|
|
148
138
|
const endTime = performance.now();
|
|
149
139
|
const time = endTime - startTime;
|
|
150
|
-
//
|
|
151
|
-
|
|
140
|
+
// Compare responses and log differences with raw lookup values
|
|
141
|
+
const differences = [];
|
|
142
|
+
for (let i = 0; i < scopedActions.length; i++) {
|
|
143
|
+
const graphResult = graphApiResponse[i];
|
|
144
|
+
const platformResult = platformApiResponse[i];
|
|
145
|
+
const { action, scope } = scopedActions[i];
|
|
146
|
+
const { resourceType, resourceId } = scopeToResource(scope);
|
|
147
|
+
const graphCan = graphResult?.permit?.can;
|
|
148
|
+
const platformCan = platformResult?.permit?.can;
|
|
149
|
+
// Log the raw lookup values for debugging
|
|
150
|
+
const graphResponseAtPath = graphApiRawResponse?.[resourceType]?.[String(resourceId)]?.[action];
|
|
151
|
+
logger.info({
|
|
152
|
+
tag: 'authorization-service-api-comparison-detail',
|
|
153
|
+
action,
|
|
154
|
+
scope,
|
|
155
|
+
resourceType,
|
|
156
|
+
resourceId,
|
|
157
|
+
graphResponseAtPath,
|
|
158
|
+
graphCan,
|
|
159
|
+
platformCan,
|
|
160
|
+
}, `API comparison detail for ${action} on ${resourceType}/${resourceId}`);
|
|
161
|
+
if (graphCan !== platformCan) {
|
|
162
|
+
differences.push({
|
|
163
|
+
action,
|
|
164
|
+
scope,
|
|
165
|
+
resourceType,
|
|
166
|
+
resourceId,
|
|
167
|
+
graphResponseAtPath,
|
|
168
|
+
graphCan,
|
|
169
|
+
platformCan,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
const isSame = differences.length === 0;
|
|
174
|
+
logger.info({
|
|
175
|
+
tag: 'authorization-service-api-comparison',
|
|
176
|
+
accountId,
|
|
177
|
+
userId,
|
|
178
|
+
profile,
|
|
179
|
+
scopedActionsCount: scopedActions.length,
|
|
180
|
+
isSame,
|
|
181
|
+
differencesCount: differences.length,
|
|
182
|
+
differences: differences.length > 0 ? differences : undefined,
|
|
183
|
+
timeMs: time,
|
|
184
|
+
}, `API comparison: graphApi vs platformApi - ${isSame ? 'SAME' : 'DIFFERENT'}`);
|
|
185
|
+
// Record metrics for each authorization check (using platform response)
|
|
186
|
+
for (const obj of platformApiResponse) {
|
|
152
187
|
const { action, scope } = obj.scopedAction;
|
|
153
188
|
const { resourceType } = scopeToResource(scope);
|
|
154
189
|
const isAuthorized = obj.permit.can;
|
|
155
190
|
sendAuthorizationCheckResponseTimeMetric(resourceType, action, isAuthorized, 200, time);
|
|
156
|
-
recordAuthorizationTiming(
|
|
191
|
+
recordAuthorizationTiming('platform', time, 'canActionInScopeMultiple');
|
|
157
192
|
}
|
|
158
|
-
|
|
193
|
+
// Return platform API response
|
|
194
|
+
return platformApiResponse;
|
|
159
195
|
}
|
|
160
196
|
static async isAuthorizedSingular(accountId, userId, resources, action) {
|
|
161
197
|
const { authorizationObjects } = createAuthorizationParams(resources, action);
|
|
@@ -21,8 +21,12 @@ export declare class GraphApi {
|
|
|
21
21
|
private static mapResponse;
|
|
22
22
|
/**
|
|
23
23
|
* Performs a complete authorization check using the Graph API
|
|
24
|
+
* Returns both the mapped response and raw response for debugging
|
|
24
25
|
*/
|
|
25
|
-
checkPermissions(accountId: number, userId: number, scopedActions: ScopedAction[]): Promise<
|
|
26
|
+
checkPermissions(accountId: number, userId: number, scopedActions: ScopedAction[]): Promise<{
|
|
27
|
+
mapped: ScopedActionResponseObject[];
|
|
28
|
+
raw: GraphIsAllowedResponse;
|
|
29
|
+
}>;
|
|
26
30
|
private static ensureGraphReason;
|
|
27
31
|
}
|
|
28
32
|
//# sourceMappingURL=graph-api.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-api.d.ts","sourceRoot":"","sources":["../../../src/clients/graph-api.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,YAAY,EACZ,0BAA0B,EAG3B,MAAM,mCAAmC,CAAC;AAG3C,OAAO,EAEL,sBAAsB,EAMvB,MAAM,0BAA0B,CAAC;AAQlC;;GAEG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IACxC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;;IAezC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAyB/B;;OAEG;IACG,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAiCzG;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IAiC1B
|
|
1
|
+
{"version":3,"file":"graph-api.d.ts","sourceRoot":"","sources":["../../../src/clients/graph-api.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,YAAY,EACZ,0BAA0B,EAG3B,MAAM,mCAAmC,CAAC;AAG3C,OAAO,EAEL,sBAAsB,EAMvB,MAAM,0BAA0B,CAAC;AAQlC;;GAEG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IACxC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;;IAezC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAyB/B;;OAEG;IACG,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAiCzG;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IAiC1B;;;OAGG;IACG,gBAAgB,CACpB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,YAAY,EAAE,GAC5B,OAAO,CAAC;QAAE,MAAM,EAAE,0BAA0B,EAAE,CAAC;QAAC,GAAG,EAAE,sBAAsB,CAAA;KAAE,CAAC;IAOjF,OAAO,CAAC,MAAM,CAAC,iBAAiB;CAWjC"}
|
|
@@ -113,11 +113,13 @@ class GraphApi {
|
|
|
113
113
|
}
|
|
114
114
|
/**
|
|
115
115
|
* Performs a complete authorization check using the Graph API
|
|
116
|
+
* Returns both the mapped response and raw response for debugging
|
|
116
117
|
*/
|
|
117
118
|
async checkPermissions(accountId, userId, scopedActions) {
|
|
118
119
|
const authToken = signAuthorizationHeader({ appName: this.consumerAppName, accountId, userId });
|
|
119
|
-
const
|
|
120
|
-
|
|
120
|
+
const rawResponse = await this.fetchPermissions(authToken, scopedActions);
|
|
121
|
+
const mappedResponse = GraphApi.mapResponse(scopedActions, rawResponse);
|
|
122
|
+
return { mapped: mappedResponse, raw: rawResponse };
|
|
121
123
|
}
|
|
122
124
|
static ensureGraphReason(reason, context) {
|
|
123
125
|
if (!reason || typeof reason !== 'object' || typeof reason.key !== 'string') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mondaydotcomorg/monday-authorization",
|
|
3
|
-
"version": "3.5.1-debug-getprofile-not-resolving-to-internal-
|
|
3
|
+
"version": "3.5.1-debug-getprofile-not-resolving-to-internal-d02966c",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
@@ -173,22 +173,18 @@ export class AuthorizationService {
|
|
|
173
173
|
userId,
|
|
174
174
|
};
|
|
175
175
|
|
|
176
|
-
console.log('[AuthorizationService.getProfile] Debug info:', debugInfo);
|
|
177
176
|
logger.info({ tag: 'authorization-service', ...debugInfo }, 'AuthorizationService.getProfile debug info');
|
|
178
177
|
|
|
179
178
|
if (isInAllowedApps) {
|
|
180
179
|
const profile = getProfile();
|
|
181
|
-
console.log('[AuthorizationService.getProfile] Returning profile from ALLOWED_SDK_PLATFORM_PROFILES_KEY:', profile);
|
|
182
180
|
logger.info({ tag: 'authorization-service', profile }, 'Returning profile from ALLOWED_SDK_PLATFORM_PROFILES_KEY');
|
|
183
181
|
return profile;
|
|
184
182
|
}
|
|
185
183
|
if (isInReleaseApps && isFeatureFlagReleased) {
|
|
186
184
|
const profile = getProfile();
|
|
187
|
-
console.log('[AuthorizationService.getProfile] Returning profile from IN_RELEASE_SDK_PLATFORM_PROFILES_KEY:', profile);
|
|
188
185
|
logger.info({ tag: 'authorization-service', profile }, 'Returning profile from IN_RELEASE_SDK_PLATFORM_PROFILES_KEY');
|
|
189
186
|
return profile;
|
|
190
187
|
}
|
|
191
|
-
console.log('[AuthorizationService.getProfile] Returning default PlatformProfile.APP');
|
|
192
188
|
logger.info({ tag: 'authorization-service', profile: PlatformProfile.APP }, 'Returning default PlatformProfile.APP');
|
|
193
189
|
return PlatformProfile.APP;
|
|
194
190
|
}
|
|
@@ -202,43 +198,103 @@ export class AuthorizationService {
|
|
|
202
198
|
return [];
|
|
203
199
|
}
|
|
204
200
|
|
|
205
|
-
const shouldNavigateToGraph = Boolean(
|
|
206
|
-
this.igniteClient?.isReleased(NAVIGATE_CAN_ACTION_IN_SCOPE_TO_GRAPH_FF, { accountId, userId })
|
|
207
|
-
);
|
|
208
|
-
|
|
209
201
|
const startTime = performance.now();
|
|
210
|
-
let scopedActionResponseObjects: ScopedActionResponseObject[];
|
|
211
|
-
let apiType: 'graph' | 'platform';
|
|
212
202
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
scopedActionResponseObjects = await this.graphApi.checkPermissions(accountId, userId, scopedActions);
|
|
216
|
-
} else {
|
|
217
|
-
apiType = 'platform';
|
|
218
|
-
const profile = this.getProfile(accountId, userId);
|
|
219
|
-
const internalAuthToken = AuthorizationInternalService.generateInternalAuthToken(accountId, userId);
|
|
203
|
+
// Always call both APIs for comparison
|
|
204
|
+
const graphApiPromise = this.graphApi.checkPermissions(accountId, userId, scopedActions);
|
|
220
205
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
206
|
+
const profile = this.getProfile(accountId, userId);
|
|
207
|
+
const internalAuthToken = AuthorizationInternalService.generateInternalAuthToken(accountId, userId);
|
|
208
|
+
const platformApiPromise = this.platformApi.checkPermissions(
|
|
209
|
+
profile,
|
|
210
|
+
internalAuthToken,
|
|
211
|
+
userId,
|
|
212
|
+
scopedActions
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
const [graphApiResult, platformApiResponse] = await Promise.all([graphApiPromise, platformApiPromise]);
|
|
216
|
+
const graphApiResponse = graphApiResult.mapped;
|
|
217
|
+
const graphApiRawResponse = graphApiResult.raw;
|
|
228
218
|
|
|
229
219
|
const endTime = performance.now();
|
|
230
220
|
const time = endTime - startTime;
|
|
231
221
|
|
|
232
|
-
//
|
|
233
|
-
|
|
222
|
+
// Compare responses and log differences with raw lookup values
|
|
223
|
+
const differences: Array<{
|
|
224
|
+
action: string;
|
|
225
|
+
scope: ScopeOptions;
|
|
226
|
+
resourceType: string;
|
|
227
|
+
resourceId: number;
|
|
228
|
+
graphResponseAtPath: unknown;
|
|
229
|
+
graphCan: boolean | undefined;
|
|
230
|
+
platformCan: boolean | undefined;
|
|
231
|
+
}> = [];
|
|
232
|
+
|
|
233
|
+
for (let i = 0; i < scopedActions.length; i++) {
|
|
234
|
+
const graphResult = graphApiResponse[i];
|
|
235
|
+
const platformResult = platformApiResponse[i];
|
|
236
|
+
|
|
237
|
+
const { action, scope } = scopedActions[i];
|
|
238
|
+
const { resourceType, resourceId } = scopeToResource(scope);
|
|
239
|
+
|
|
240
|
+
const graphCan = graphResult?.permit?.can;
|
|
241
|
+
const platformCan = platformResult?.permit?.can;
|
|
242
|
+
|
|
243
|
+
// Log the raw lookup values for debugging
|
|
244
|
+
const graphResponseAtPath = graphApiRawResponse?.[resourceType]?.[String(resourceId)]?.[action];
|
|
245
|
+
|
|
246
|
+
logger.info({
|
|
247
|
+
tag: 'authorization-service-api-comparison-detail',
|
|
248
|
+
action,
|
|
249
|
+
scope,
|
|
250
|
+
resourceType,
|
|
251
|
+
resourceId,
|
|
252
|
+
graphResponseAtPath,
|
|
253
|
+
graphCan,
|
|
254
|
+
platformCan,
|
|
255
|
+
}, `API comparison detail for ${action} on ${resourceType}/${resourceId}`);
|
|
256
|
+
|
|
257
|
+
if (graphCan !== platformCan) {
|
|
258
|
+
differences.push({
|
|
259
|
+
action,
|
|
260
|
+
scope,
|
|
261
|
+
resourceType,
|
|
262
|
+
resourceId,
|
|
263
|
+
graphResponseAtPath,
|
|
264
|
+
graphCan,
|
|
265
|
+
platformCan,
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const isSame = differences.length === 0;
|
|
271
|
+
|
|
272
|
+
logger.info(
|
|
273
|
+
{
|
|
274
|
+
tag: 'authorization-service-api-comparison',
|
|
275
|
+
accountId,
|
|
276
|
+
userId,
|
|
277
|
+
profile,
|
|
278
|
+
scopedActionsCount: scopedActions.length,
|
|
279
|
+
isSame,
|
|
280
|
+
differencesCount: differences.length,
|
|
281
|
+
differences: differences.length > 0 ? differences : undefined,
|
|
282
|
+
timeMs: time,
|
|
283
|
+
},
|
|
284
|
+
`API comparison: graphApi vs platformApi - ${isSame ? 'SAME' : 'DIFFERENT'}`
|
|
285
|
+
);
|
|
286
|
+
|
|
287
|
+
// Record metrics for each authorization check (using platform response)
|
|
288
|
+
for (const obj of platformApiResponse) {
|
|
234
289
|
const { action, scope } = obj.scopedAction;
|
|
235
290
|
const { resourceType } = scopeToResource(scope);
|
|
236
291
|
const isAuthorized = obj.permit.can;
|
|
237
292
|
sendAuthorizationCheckResponseTimeMetric(resourceType, action, isAuthorized, 200, time);
|
|
238
|
-
recordAuthorizationTiming(
|
|
293
|
+
recordAuthorizationTiming('platform', time, 'canActionInScopeMultiple');
|
|
239
294
|
}
|
|
240
295
|
|
|
241
|
-
|
|
296
|
+
// Return platform API response
|
|
297
|
+
return platformApiResponse;
|
|
242
298
|
}
|
|
243
299
|
|
|
244
300
|
private static async isAuthorizedSingular(
|
package/src/clients/graph-api.ts
CHANGED
|
@@ -146,15 +146,17 @@ export class GraphApi {
|
|
|
146
146
|
|
|
147
147
|
/**
|
|
148
148
|
* Performs a complete authorization check using the Graph API
|
|
149
|
+
* Returns both the mapped response and raw response for debugging
|
|
149
150
|
*/
|
|
150
151
|
async checkPermissions(
|
|
151
152
|
accountId: number,
|
|
152
153
|
userId: number,
|
|
153
154
|
scopedActions: ScopedAction[]
|
|
154
|
-
): Promise<ScopedActionResponseObject[]> {
|
|
155
|
+
): Promise<{ mapped: ScopedActionResponseObject[]; raw: GraphIsAllowedResponse }> {
|
|
155
156
|
const authToken = signAuthorizationHeader({ appName: this.consumerAppName, accountId, userId });
|
|
156
|
-
const
|
|
157
|
-
|
|
157
|
+
const rawResponse = await this.fetchPermissions(authToken, scopedActions);
|
|
158
|
+
const mappedResponse = GraphApi.mapResponse(scopedActions, rawResponse);
|
|
159
|
+
return { mapped: mappedResponse, raw: rawResponse };
|
|
158
160
|
}
|
|
159
161
|
|
|
160
162
|
private static ensureGraphReason(
|