Skip to content

feat(gate): add OAuth2 Client Credentials auth for registration gate#924

Merged
aarora79 merged 5 commits intomainfrom
feat/917-oauth2-gate-token-injection
May 3, 2026
Merged

feat(gate): add OAuth2 Client Credentials auth for registration gate#924
aarora79 merged 5 commits intomainfrom
feat/917-oauth2-gate-token-injection

Conversation

@aarora79
Copy link
Copy Markdown
Contributor

@aarora79 aarora79 commented May 2, 2026

Summary

  • Adds oauth2_client_credentials as a fourth auth type for the Registration Gate, enabling enterprise environments where the gate endpoint is protected by an OAuth2 identity provider (Entra ID, Okta, Auth0, Keycloak, Cognito)
  • The registry acquires a fresh access token via the OAuth2 Client Credentials flow (RFC 6749 Section 4.4) before each gate invocation
  • Fail-closed design: if token acquisition fails, registration is blocked immediately (no retry loop for token failures)
  • All 4 new config parameters propagated across Docker, Terraform/ECS, Helm/EKS, and System Config page
  • Exposes registration webhook settings on System Config page (previously only in config.py)

New Configuration Parameters

Variable Description
REGISTRATION_GATE_OAUTH2_TOKEN_URL OAuth2 token endpoint URL
REGISTRATION_GATE_OAUTH2_CLIENT_ID OAuth2 client ID
REGISTRATION_GATE_OAUTH2_CLIENT_SECRET OAuth2 client secret (sensitive)
REGISTRATION_GATE_OAUTH2_SCOPE OAuth2 scope parameter (optional)

Files Changed (19 files)

Core implementation:

  • registry/schemas/registration_gate_models.py - New OAUTH2_CLIENT_CREDENTIALS enum value
  • registry/core/config.py - 4 new settings fields
  • registry/services/registration_gate_service.py - Token acquisition, async auth headers, fail-closed logic, startup validation
  • registry/api/config_routes.py - System Config page: OAuth2 gate fields + new webhook notifications group

Deployment surfaces:

  • .env.example, 3x docker-compose*.yml, 5x terraform/aws-ecs/*, 3x charts/*

Tests and docs:

  • tests/unit/services/test_registration_gate_service.py - 14 new tests
  • docs/registration-webhooks.md - OAuth2 Client Credentials documentation

Test plan

  • All 65 gate-specific unit tests pass (14 new + 51 existing after async conversion)
  • Full test suite: 2626 passed, 67 skipped, 48.26% coverage
  • All Python files compile-checked
  • Ruff lint clean (only pre-existing UP042 warnings)
  • E2E: registered agent with Entra OAuth2 gate auth, gate received real Entra JWT
  • E2E: invalid client secret returns 403 fail-closed, zero gate calls made
  • Decoded Entra JWT on gate receiver confirms correct issuer, appid, tenant
  • System Config page shows webhook fields + OAuth2 gate fields with masked secrets

Closes #917

…917)

Add `oauth2_client_credentials` as a fourth auth type for the
registration gate. The registry acquires a fresh access token via
the OAuth2 Client Credentials flow (RFC 6749 Section 4.4) before
each gate invocation.

- Add `_acquire_oauth2_token()` async function for token acquisition
- Convert `_build_auth_headers()` to async with new OAuth2 branch
- Fail-closed: block registration immediately if token cannot be acquired
- Add startup validation and test token acquisition in `verify_gate_connectivity()`
- Propagate 4 new config parameters across all deployment surfaces
  (Docker, Terraform/ECS, Helm/EKS, System Config page)
- Add 14 new unit tests covering all OAuth2 code paths
- Update registration-webhooks.md with OAuth2 documentation

Closes #917
Comment thread registry/services/registration_gate_service.py Fixed
aarora79 added 4 commits May 3, 2026 02:30
Add the 4 registration webhook fields (URL, auth header, auth token,
timeout) to the System Config page under a new "Registration Webhook
(Notifications)" group. These settings were already in config.py but
not visible in the UI.
…tion

Add a detailed table describing the 4 new OAuth2 Client Credentials
parameters (token URL, client ID, client secret, scope) with required
flags, descriptions, and deployment surface availability.
Step-by-step guide covering Entra App Registration setup, registry
configuration, verification, and notes on using other IdPs (Okta,
Auth0, Keycloak, Cognito).
CodeQL flagged clear-text logging of client_id as a credential.
Show only the first 8 characters to avoid the finding while still
being useful for debugging.
Comment thread registry/services/registration_gate_service.py Dismissed
@aarora79 aarora79 merged commit 36e6474 into main May 3, 2026
21 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.

Feature Request: Dynamic Access Token Injection for Webhook Invocation

2 participants