Skip to content

Conversation

@jhrozek
Copy link
Contributor

@jhrozek jhrozek commented Feb 9, 2026

Previously, the embedded auth server converted all upstream configs to OAuth2Config, which meant OIDCProviderImpl was never instantiated even when the upstream was configured as type "oidc". This caused OIDC features like ID token validation and automatic discovery to be silently skipped.

Refactor UpstreamConfig to carry an explicit provider type ("oidc" or "oauth2") with separate OIDCConfig and OAuth2Config fields. The upstream factory now dispatches on type, creating OIDCProviderImpl (with OIDC discovery and ID token validation) for OIDC upstreams and BaseOAuth2Provider for OAuth2 upstreams. Config validation enforces mutual exclusivity between the two config fields.

Tested end-to-end with Google as the OIDC upstream:

    upstreamProviders:
      - name: google
        type: oidc
        oidcConfig:
          issuerUrl: "https://accounts.google.com"
          clientId: "<google-client-id>"
          clientSecretRef:
            name: google-oauth-secret
            key: client-secret
          redirectUri: "https://example.com/oauth/callback"
          scopes:
            - openid
            - email

Fixes: https://github.com/stacklok/stacklok-epics/issues/235

Previously, the embedded auth server converted all upstream configs to
OAuth2Config, which meant OIDCProviderImpl was never instantiated even
when the upstream was configured as type "oidc". This caused OIDC
features like ID token validation and automatic discovery to be silently
skipped.

Refactor UpstreamConfig to carry an explicit provider type ("oidc" or
"oauth2") with separate OIDCConfig and OAuth2Config fields. The upstream
factory now dispatches on type, creating OIDCProviderImpl (with OIDC
discovery and ID token validation) for OIDC upstreams and
BaseOAuth2Provider for OAuth2 upstreams. Config validation enforces
mutual exclusivity between the two config fields.

Tested end-to-end with Google as the OIDC upstream:

```yaml
    upstreamProviders:
      - name: google
        type: oidc
        oidcConfig:
          issuerUrl: "https://accounts.google.com"
          clientId: "<google-client-id>"
          clientSecretRef:
            name: google-oauth-secret
            key: client-secret
          redirectUri: "https://example.com/oauth/callback"
          scopes:
            - openid
            - email
```yaml

Fixes: stacklok/stacklok-epics#235
@jhrozek jhrozek requested review from tgrunnagle and removed request for ChrisJBurns, JAORMX and yrobla February 9, 2026 15:53
@github-actions github-actions bot added the size/L Large PR: 600-999 lines changed label Feb 9, 2026
@codecov
Copy link

codecov bot commented Feb 9, 2026

Codecov Report

❌ Patch coverage is 90.62500% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.30%. Comparing base (1e626bb) to head (12a5be9).
⚠️ Report is 24 commits behind head on main.

Files with missing lines Patch % Lines
pkg/authserver/config.go 78.94% 2 Missing and 2 partials ⚠️
pkg/authserver/server_impl.go 81.81% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3720      +/-   ##
==========================================
+ Coverage   66.04%   66.30%   +0.25%     
==========================================
  Files         417      426       +9     
  Lines       41255    41765     +510     
==========================================
+ Hits        27247    27692     +445     
- Misses      11915    11958      +43     
- Partials     2093     2115      +22     

☔ 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.

@jhrozek jhrozek merged commit 9630ae3 into main Feb 9, 2026
36 checks passed
@jhrozek jhrozek deleted the auth-proxy-pr-15-oidc-plumbing branch February 9, 2026 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Large PR: 600-999 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants