Skip to content

fix: lazily create OIDC Issuer to support Kubernetes tokens#609

Merged
spencerschrock merged 1 commit intosigstore:mainfrom
SequeI:IssuerBug
Jan 29, 2026
Merged

fix: lazily create OIDC Issuer to support Kubernetes tokens#609
spencerschrock merged 1 commit intosigstore:mainfrom
SequeI:IssuerBug

Conversation

@SequeI
Copy link
Copy Markdown
Contributor

@SequeI SequeI commented Jan 29, 2026

Summary

Issuer was created early in __init__, fetching OIDC discovery config. Kubernetes OIDC providers lack authorization_endpoint/token_endpoint, causing failures even when identity_token was provided directly.

Signing failed with error: OIDC issuer returned invalid configuration: 2 validation errors for _OpenIDConfiguration
authorization_endpoint
  Field required [type=missing, input_value={'issuer': 'https://rh-oi/...', 'iat', 'iss', 'sub']}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/missing
token_endpoint
  Field required [type=missing, input_value={'issuer': 'https://rh-oi/...', 'iat', 'iss', 'sub']}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/missing

Now Issuer is only created when OAuth flow is needed, after FIRST checking if OIDC token was supplied directly via args, or env.

Checklist
  • All commits are signed-off, using DCO
  • All new code has docstrings and type annotations
  • All new code is covered by tests. Aim for at least 90% coverage. CI is configured to highlight lines not covered by tests.
  • Public facing changes are paired with documentation changes
  • Release note has been added to CHANGELOG.md if needed

@SequeI SequeI requested review from a team as code owners January 29, 2026 18:29
stefanberger
stefanberger previously approved these changes Jan 29, 2026
Copy link
Copy Markdown
Contributor

@spencerschrock spencerschrock left a comment

Choose a reason for hiding this comment

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

Switching this to lazy init seems fine to me, one question though

Comment on lines +156 to +157
issuer = sigstore_oidc.Issuer(self._oidc_issuer)
return issuer.identity_token(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Any idea how heavy this is as it fetches "an OpenID Connect configuration file, which is then used to bootstrap the issuer's state"

We were previously storing this issuer after creation, and now it gets reinitialized every call to _get_identity_token

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point, did not think of this. Fixed to cache Issuer object

Issuer was created eagerly in __init__, fetching OIDC discovery config.
Kubernetes OIDC providers lack authorization_endpoint/token_endpoint,
causing failures even when identity_token was provided directly.

Now Issuer is lazily created and cached when OAuth flow is needed.

Signed-off-by: SequeI <asiek@redhat.com>
Copy link
Copy Markdown
Contributor

@spencerschrock spencerschrock left a comment

Choose a reason for hiding this comment

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

Thank you!

@spencerschrock spencerschrock merged commit ad4451a into sigstore:main Jan 29, 2026
52 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