Repository navigation
feat(sso): three-tier roles with access-key role association - #2
Merged
Merged
Conversation
Adds member between admin and viewer, and authorizes access-key requests (/api/v2, /mcp) by the key owner's stored role instead of request headers — so a user can hold an API token without their token carrying write access. - models/proxyAuthRole.ts: persists each user's last proxy-asserted role (viewer|member|admin), groups and lastSeenAt. Access-key requests carry no proxy headers, so they are authorized against this record. - middleware/proxyAuthRoles.ts: app-wide guard. Browser (proxy) requests take the role from X-Forwarded-Groups and refresh the record; access-key requests resolve the owner, read the stored role, and reject keys whose owner has not signed in within PROXY_AUTH_ACCESS_KEY_MAX_IDLE_DAYS. MCP writes are gated per tool (read-only tools need viewer, *_source need admin, rest need member). Non-admin clickhouse-proxy queries are forced to readonly=2. - integrate.mjs: role guard now imported from proxyAuthRoles; new step gates MCP tools in mcp/utils/registerTool.ts. - New env: PROXY_AUTH_MEMBER_GROUPS, PROXY_AUTH_ACCESS_KEY_MAX_IDLE_DAYS. - Default build tag moved to @hyperdx/app@2.42.0.
🟡 Tier 3 — StandardIntroduces new logic, modifies core functionality, or touches areas with non-trivial risk. Why this tier:
Review process: Full human review — logic, architecture, edge cases. Stats
|
PR ReviewThe next push will retry automatically. |
This was referenced Oct 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Two gaps in the current proxy-auth overlay:
X-Forwarded-Groupsheader. Access-key requests (/api/v2,/mcp) carry no such header, so the guard treated them as viewers and denied every write — which is why the Terraform provider'sPUT /api/v2/dashboardsreturns403 Read-only access.Change
models/proxyAuthRole.ts— persists each user's last proxy-asserted role (viewer|member|admin), groups andlastSeenAt. Access-key requests have no proxy headers, so they are authorized against this record.middleware/proxyAuthRoles.ts— app-wide guard mounted before every router:X-Forwarded-Groups; the record is refreshed (at most hourly unless it changes)./api/v2,/mcp): resolve the key owner, read the stored role, ignore headers. Keys whose owner hasn't signed in via SSO withinPROXY_AUTH_ACCESS_KEY_MAX_IDLE_DAYSare rejected, so removing someone from the IdP group revokes their key.POST /mcp, so writes are gated per tool (read-only tools -> viewer,*_source-> admin, rest -> member).clickhouse-proxyqueries are forced toreadonly=2.integrate.mjs— the guard is imported fromproxyAuthRoles; a new codemod step gates MCP tools inmcp/utils/registerTool.ts. Rebased ontomain, so it sits alongside the x-axis step from fix(sso): show dates on time-chart x-axis ticks for ranges over a day #1: axis is step 4, MCP gating step 5.PROXY_AUTH_MEMBER_GROUPS,PROXY_AUTH_ACCESS_KEY_MAX_IDLE_DAYS(default 30).@hyperdx/app@2.42.0.Roles
PROXY_AUTH_ADMIN_GROUPSPROXY_AUTH_MEMBER_GROUPSValidation
@hyperdx/app@2.39.1and2.42.0(all five codemod steps; idempotent on re-run).User.accessKey,getCounter, modelsObjectId,registerToolanchors) exists in both tags.integrate.mjspassesnode --checkand prettier.Deploy notes
ProxyAuthRolecollection is empty. Each user's record is created on their first browser SSO sign-in. So the provider's API-key owner must sign in once (as member/admin) on the new image before/api/v2writes are authorized — otherwise the key is rejected as "inactive".