Skip to content

Commit 66bac24

Browse files
committed
fix: review comments
1 parent 36251ff commit 66bac24

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

packages/spacecat-shared-http-utils/src/auth/handlers/ims.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ function isUserASOAdmin(organizations) {
105105
/**
106106
* Checks whether the read-only org gate flag is enabled for the user's first
107107
* IMS organization. When true, ALL IMS-authenticated users in that org are
108-
* blocked (not just RO admins) this intentionally forces the entire org to
108+
* blocked (not just RO admins) - this intentionally forces the entire org to
109109
* authenticate via the JWT/auth-service path instead.
110110
*
111111
* NOTE: Only the first org in the array is evaluated. Multi-org users whose
@@ -122,7 +122,7 @@ async function isOrgBlockedFromImsAuth(context, organizations) {
122122
const ldClient = LaunchDarklyClient.createFrom(context);
123123
if (!ldClient) return false;
124124

125-
// Only evaluate the first org see NOTE above.
125+
// Only evaluate the first org - see NOTE above.
126126
const ident = organizations[0]?.orgRef?.ident;
127127
if (!ident) return false;
128128

packages/spacecat-shared-http-utils/src/auth/read-only-admin-wrapper.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ async function evaluateFeatureFlag(context, authInfo) {
5757
* wrapper), this wrapper checks whether the authenticated user is a read-only admin.
5858
* If so it:
5959
*
60-
* 1. Evaluates the `FT_LLMO-3008` LaunchDarkly feature flag (fail-closed).
60+
* 1. Evaluates the `FT_READ_ONLY_ORG` LaunchDarkly feature flag (fail-closed).
6161
* 2. Resolves the route's action from the routeCapabilities map and blocks
6262
* write operations (or unmapped routes) for RO admins.
6363
* 3. Emits a structured audit log entry for allowed RO admin requests.
6464
*
6565
* Non-RO-admin requests pass through untouched.
6666
*
6767
* @param {Function} fn - The handler to wrap.
68-
* @param {{ routeCapabilities?: Object<string, string> }} opts - Map of route
68+
* @param {{ routeCapabilities: Object<string, string> }} opts - Required map of route
6969
* patterns (e.g. 'GET /sites/:siteId') to action strings ('read' | 'write').
7070
* @returns {Function} A wrapped handler.
7171
*/
@@ -84,6 +84,7 @@ export function readOnlyAdminWrapper(fn, { routeCapabilities } = {}) {
8484
if (!ffEnabled) {
8585
log.warn({
8686
tag: 'ro-admin',
87+
email: authInfo.getProfile?.()?.email,
8788
org: authInfo.getTenantIds?.()[0],
8889
}, 'Feature flag disabled, denying RO admin access');
8990
return forbidden('Forbidden');
@@ -99,6 +100,7 @@ export function readOnlyAdminWrapper(fn, { routeCapabilities } = {}) {
99100
if (action !== 'read') {
100101
log.warn({
101102
tag: 'ro-admin',
103+
email: authInfo.getProfile?.()?.email,
102104
method: context.pathInfo?.method,
103105
suffix: context.pathInfo?.suffix,
104106
org: authInfo.getTenantIds?.()[0],
@@ -109,6 +111,7 @@ export function readOnlyAdminWrapper(fn, { routeCapabilities } = {}) {
109111

110112
log.info({
111113
tag: 'ro-admin-audit',
114+
email: authInfo.getProfile?.()?.email,
112115
method: context.pathInfo?.method,
113116
suffix: context.pathInfo?.suffix,
114117
org: authInfo.getTenantIds?.()[0],

packages/spacecat-shared-http-utils/src/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export declare function forbidden(message?: string, headers?: object): Response;
4545
*/
4646
export function readOnlyAdminWrapper(
4747
fn: Function,
48-
opts?: { routeCapabilities?: Record<string, string> },
48+
opts: { routeCapabilities: Record<string, string> },
4949
): Function;
5050

5151
/**

0 commit comments

Comments
 (0)