Skip to content

feat(relay): add resource identity auth for relays#6515

Merged
saifsmailbox98 merged 24 commits into
mainfrom
saif/pam-215-build-resource-identity-auth-for-relays
May 22, 2026
Merged

feat(relay): add resource identity auth for relays#6515
saifsmailbox98 merged 24 commits into
mainfrom
saif/pam-215-build-resource-identity-auth-for-relays

Conversation

@saifsmailbox98
Copy link
Copy Markdown
Contributor

@saifsmailbox98 saifsmailbox98 commented May 18, 2026

Context

Move relays to resource identity auth (same abstraction gateways use). Relays can now authenticate via enrollment tokens or AWS IAM without needing a machine identity.

Existing machine identity relays and instance relays are unaffected.

CLI companion: Infisical/cli#237

Screenshots

Type

  • Fix
  • Feature
  • Improvement
  • Breaking
  • Docs
  • Chore

Checklist

  • Title follows the conventional commit format: type(scope): short description (scope is optional, e.g., fix: prevent crash on sync or fix(api): handle null response).
  • Tested locally
  • Updated docs (if needed)
  • Updated CLAUDE.md files (if needed)
  • Read the contributing guide

Extends the resource auth method abstraction (built for gateways) to
relays, allowing org relays to authenticate via enrollment tokens or
AWS IAM instead of requiring a machine identity.

Backend:
- Migration: add relayId to resource_auth_methods, tokenVersion to relays
- Auth: RELAY_ACCESS_TOKEN / ActorType.RELAY / AuthMode.RELAY_ACCESS_TOKEN
- Resource auth method service extended for relay resources
- New v2 relay router (create, get, patch, login, connect, heartbeat,
  generate-enrollment-token, revoke)
- New relay service methods (createRelay, connectRelay, heartbeatRelay)
- RevokeRelayAccess permission added
- Audit log events for relay create/delete/enrollment-token
- v1 org relay endpoints hidden from API docs (still functional)

Frontend:
- Relay detail page with auth method display, edit modal, deploy section
- Reworked deploy modal: resource auth flow (name + host → create → token)
- Clickable relay rows navigate to detail page
- API hooks: useCreateRelay, useGetRelayById, useUpdateRelayAuthMethod,
  useGenerateRelayEnrollmentToken, useRevokeRelayAccess
- RevokeRelayAccess in permission types, role editor, Zod schema
- Deleted old machine-identity deployment method components

Existing relays on machine identity auth and instance relays on
RELAY_AUTH_SECRET are completely unaffected.
Replaces the table-based list views and separate detail pages with a
split view layout using v3 components:

- Left card: searchable item list with health dot indicators
- Right card: inline detail panel with general info, auth method,
  deploy button, connected resources
- Gateways/Pools sub-tabs using v3 filled Tabs
- Responsive: stacks on mobile (<1100px) with back button
- Create buttons at section level (Create Gateway / Create Pool / Create Relay)
- Relay deploy modal simplified to name + host only (no auth method step)
- Deleted old GatewayTab, RelayTab, PoolDetailSheet, and standalone
  detail page components (GatewayPageHeader, GatewayDetailsCard, etc.)

All existing modals, API hooks, and permissions unchanged.
…lth status

- Add GET /v2/relays/:relayId/gateways endpoint returning gateways
  connected to a relay, permission-gated by ListRelays only
- Add RelayConnectedGatewaysSection with accordion grouping by health
  status (Healthy/Unreachable/Unregistered), matching the gateway
  connected resources pattern
- Rework relay create modal: name + host only, navigates to detail
  page on success (deploy command available there)
- Fix relay list health status bug: no heartbeat was showing "Healthy"
  instead of "Unregistered"
- Make relay list rows clickable (navigate to detail page for org relays)
- Rename "Deploy Relay" → "Create Relay" button and modal title
…ixes

- Add host update to PATCH /v2/relays/:relayId with EditRelays permission
  and verifyHostInputValidity check
- Add Edit Relay dialog on detail page General section (matching auth
  method edit pattern)
- Add ActorType.RELAY to audit-log plugin (fixes 400 on relay connect)
- Add orgId mismatch check in inject-identity for RELAY_ACCESS_TOKEN
- Eliminate redundant DB fetch in PATCH handler (updateRelay result
  reused instead of separate getRelayById)
- Add audit log for host updates
- Frontend mutation only sends defined fields (omits undefined host/authMethod)
- Rename useUpdateRelayAuthMethod → useUpdateRelay, accept optional host
- Add createdAt + heartbeat subtitle to connected gateways rows
- Align name validation with v1 slugSchema (1-32 chars)
@linear
Copy link
Copy Markdown

linear Bot commented May 18, 2026

PAM-215

@infisical-review-police
Copy link
Copy Markdown

💬 Discussion in Slack: #pr-review-infisical-6515-feat-relay-add-resource-identity-auth-for-relays

Posted by Review Police — reviews, comments, new commits, and CI failures will stream into this channel.

Comment thread backend/src/ee/routes/v2/relay-router.ts
Comment thread backend/src/ee/routes/v2/relay-router.ts
…ort fix

- Add resource type check on loginWithToken result in both relay v2
  and gateway v3 login handlers — reject enrollment tokens belonging
  to the wrong resource type with 400 before audit-logging
- Add RELAY_UPDATE event type and use it for host updates in PATCH
  handler (was incorrectly using RELAY_CREATE)
- Include host value in RELAY_UPDATE audit metadata
- Add RELAY_UPDATE to frontend audit log enum + display name
@infisical-github-bot
Copy link
Copy Markdown

infisical-github-bot Bot commented May 18, 2026

Preview environment failed to deploy.

View details in the preview orchestrator

@saifsmailbox98
Copy link
Copy Markdown
Contributor Author

@claude review once

Comment thread backend/src/ee/services/audit-log/audit-log-types.ts
Comment thread frontend/src/hooks/api/relays/mutations.tsx
- Wire RELAY_DELETE audit event in v1 delete handler
- Invalidate relay list query on update (fixes stale host in list)
- Replace token-only deploy dialog with unified RelayDeployCommandDialog
  that handles both token and AWS auth methods
- Delete old RelayEnrollmentTokenDialog (superseded)
- Rewrite relay CLI docs with enrollment-based auth as primary flow
  (token and AWS methods), legacy machine identity as secondary
- Add revoke-relay-access to organization permissions reference
Comment thread backend/src/db/migrations/20260521025807_relay-resource-auth.ts
Comment thread backend/src/ee/routes/v2/relay-router.ts Outdated
Comment thread backend/src/ee/services/relay/relay-service.ts
Comment thread backend/src/ee/services/relay/relay-service.ts
Comment thread backend/src/ee/services/resource-auth-method/resource-auth-method-service.ts Outdated
…t token

Move the resource type check from the route handlers into
loginWithToken itself, before the consumption transaction. Prevents
a cross-resource token from being burned on the wrong endpoint — the
token stays intact and a clear 400 is returned.
Route handlers (GET and PATCH) now use getOrgRelay which filters by
orgId, instead of the bare getRelayById. getRelayById stays as-is
for inject-identity.ts where org context isn't available yet.
…or heartbeat

Add optional timeoutMs to createRelayConnection (default 100s for
backward compat). Heartbeat callers (v1 and v2) now pass 15s — a
health probe doesn't need 100s to determine reachability.

Also fixes the log message that said "120 seconds" when the actual
timeout was 100s.
Comment thread docs/cli/commands/relay.mdx Outdated
- Replace machine identity provisioning step with "Create the Relay
  in the UI" step matching the gateway deployment pattern
- Update CLI commands to use --enroll-method with token/AWS auth
- Update terraform user_data to use enrollment token instead of
  machine identity token
- Keep FAQ, network/firewall, and general structure unchanged
@saifsmailbox98 saifsmailbox98 merged commit 7b15a72 into main May 22, 2026
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants