Skip to content

Conversation

@tgrunnagle
Copy link
Contributor

@tgrunnagle tgrunnagle commented Jan 28, 2026

Summary

Add the embeddedAuthServer authentication type to the MCPExternalAuthConfig CRD, enabling MCP servers in Kubernetes to integrate with an embedded OAuth2/OIDC authorization server.

Issue: stacklok/stacklok-epics#226

Changes

  • Add ExternalAuthTypeEmbeddedAuthServer constant with value "embeddedAuthServer"
  • Add EmbeddedAuthServerConfig struct with configuration for:
    • Issuer URL (HTTPS required, no trailing slash per RFC 8414)
    • Signing key secret references (1-5 keys for rotation)
    • HMAC secret references for opaque token signing
    • Token lifespan configuration (access, refresh, auth code)
    • Upstream provider configuration (OIDC or OAuth2)
    • Allowed audiences for RFC 8707 resource validation
  • Add TokenLifespanConfig, UpstreamProviderConfig, OIDCUpstreamConfig, and OAuth2UpstreamConfig structs
  • Add webhook validation ensuring:
    • Config exclusivity (embeddedAuthServer not set with other auth types)
    • Single upstream provider limit (runtime validation for future multi-IDP support)
    • Upstream provider type/config consistency
  • Add placeholder handling in controller code for future integration
  • Bump operator-crds chart version to 0.0.105

Test Plan

  • New unit tests for embeddedAuthServer webhook validation (15+ test cases)
  • Existing webhook tests pass
  • CRD generation succeeds (task operator-generate && task operator-manifests)
  • Helm template renders correctly
  • Chart linting passes

Large PR Justification

  • Most lines are generated.
  • Majority of remaining lines are unit tests with no logical redundancy.

@github-actions github-actions bot added the size/XL Extra large PR: 1000+ lines changed label Jan 28, 2026
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Large PR Detected

This PR exceeds 1000 lines of changes and requires justification before it can be reviewed.

How to unblock this PR:

Add a section to your PR description with the following format:

## Large PR Justification

[Explain why this PR must be large, such as:]
- Generated code that cannot be split
- Large refactoring that must be atomic
- Multiple related changes that would break if separated
- Migration or data transformation

Alternative:

Consider splitting this PR into smaller, focused changes (< 1000 lines each) for easier review and reduced risk.

See our Contributing Guidelines for more details.


This review will be automatically dismissed once you add the justification section.

@codecov
Copy link

codecov bot commented Jan 28, 2026

Codecov Report

❌ Patch coverage is 68.88889% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.28%. Comparing base (d3c579d) to head (1ad3ede).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...ator/api/v1alpha1/mcpexternalauthconfig_webhook.go 75.60% 5 Missing and 5 partials ⚠️
...perator/controllers/virtualmcpserver_deployment.go 0.00% 2 Missing ⚠️
...d/thv-operator/pkg/controllerutil/tokenexchange.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3488      +/-   ##
==========================================
- Coverage   65.34%   65.28%   -0.07%     
==========================================
  Files         403      403              
  Lines       39206    39223      +17     
==========================================
- Hits        25618    25605      -13     
- Misses      11607    11627      +20     
- Partials     1981     1991      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions github-actions bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Jan 28, 2026
@github-actions github-actions bot dismissed their stale review January 28, 2026 19:50

Large PR justification has been provided. Thank you!

@github-actions
Copy link
Contributor

✅ Large PR justification has been provided. The size review has been dismissed and this PR can now proceed with normal review.

@tgrunnagle tgrunnagle marked this pull request as ready for review January 28, 2026 19:52
Copy link
Contributor

@jhrozek jhrozek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the audiences field should be removed, I think it would be also nice to at least provide a nice default for scopes and redirectUrl

jhrozek
jhrozek previously approved these changes Jan 29, 2026
@tgrunnagle tgrunnagle force-pushed the auth-server_issue-226_2026-01-28 branch from 00fa629 to 6f8c0fe Compare January 29, 2026 16:54
@github-actions github-actions bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Jan 29, 2026
jhrozek
jhrozek previously approved these changes Jan 29, 2026
Add support for embedded OAuth2/OIDC authorization server configuration
in the MCPExternalAuthConfig CRD. This enables MCP servers in Kubernetes
to integrate with an embedded auth server that delegates to upstream IDPs.

New types added:
- EmbeddedAuthServerConfig: Main config with issuer, signing keys, HMAC
  secrets, token lifespans, upstream providers, and allowed audiences
- TokenLifespanConfig: Duration settings for access/refresh/auth code tokens
- UpstreamProviderConfig: Upstream IDP config with OIDC/OAuth2 support
- OIDCUpstreamConfig: OIDC-specific configuration with discovery support
- OAuth2UpstreamConfig: OAuth2-specific configuration with explicit endpoints

Webhook validation ensures:
- Mutual exclusivity between auth config types
- Upstream provider type matches its config (oidc/oauth2)
- Currently only one upstream provider is supported

Closes stacklok/stacklok-epics#226

Update deploy/charts/operator-crds/README.md

Address internal review feedback

Align CRDs with go config types

Run `task crdref-gen`

Address feedback

- Remove `AllowedAudiences` and `ScopesSupported` from `EmbeddedAuthServerConfig`
- Make `RedirectURI` optional so that a MCPExternalAuthConfig can be shared among multiple MCP servers. If not specified, it will default to `{mcp_server_url}/oauth/callback`
- Reduce code duplication in MCPExternalAuthConfig webhook and update corresponding tests
- Re run `task operator-generate && task operator-manifests`, `task build`, `task test`, `task crdref-gen`, `pre-commit run --all-files`

Update inaccurate comment

CRD updates

- Update issuer validation pattern to allow `http` schema, prohibit query, fragment
- make `HMACSecretRefs` and `SigningKeySecretRefs` optional (given ephemeral HMAC and key support)
- Run generate tasks, build, test, crdref-gen

Fix lint
And run `pre-commit run --all-files`
@tgrunnagle tgrunnagle force-pushed the auth-server_issue-226_2026-01-28 branch from 6f8c0fe to 63bca5f Compare January 30, 2026 16:29
@github-actions github-actions bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Jan 30, 2026
@github-actions github-actions bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Jan 30, 2026
@tgrunnagle tgrunnagle merged commit f9ecdf7 into main Jan 30, 2026
36 checks passed
@tgrunnagle tgrunnagle deleted the auth-server_issue-226_2026-01-28 branch January 30, 2026 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XL Extra large PR: 1000+ lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants