Skip to content

Conversation

@JAORMX
Copy link
Collaborator

@JAORMX JAORMX commented Oct 24, 2025

Summary

Add support for loading OIDC client secret from TOOLHIVE_OIDC_CLIENT_SECRET environment variable in the token validator. This is preparatory work for Kubernetes-native secret injection via SecretKeyRef.

Changes

  • ✅ Added os import to pkg/auth/token.go
  • ✅ Added environment variable fallback in NewTokenValidator()
  • ✅ Loads from TOOLHIVE_OIDC_CLIENT_SECRET when config.ClientSecret is empty

Behavior

Backward Compatible:

  • If environment variable is not set → uses config.ClientSecret as before
  • If config.ClientSecret is set → uses that value (no change)
  • If config.ClientSecret is empty AND env var is set → uses env var value

Use Case:
This enables Kubernetes operators to inject OIDC client secrets via environment variables sourced from Kubernetes Secrets, without embedding secrets in ConfigMaps or YAML manifests.

Testing

  • ✅ No functional change when environment variable is not set
  • ✅ All existing tests pass
  • ✅ Linter passes

Follow-up Work

This is Part 1 of 2 for implementing #2321:

Part 2 will add:

  • ClientSecretRef field to InlineOIDCConfig CRD
  • Controller logic to inject secrets via environment variables
  • Examples and documentation

Related

Related to #2321

🤖 Generated with Claude Code

Add support for loading OIDC client secret from TOOLHIVE_OIDC_CLIENT_SECRET
environment variable. This enables Kubernetes-native secret injection via
SecretKeyRef in future operator enhancements.

The change is backward compatible - if the environment variable is not set,
the behavior remains unchanged (uses config.ClientSecret as before).

This is preparatory work for adding SecretKeyRef support to InlineOIDCConfig
in the operator, which will be implemented in a follow-up PR.

Related to #2321

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Oct 24, 2025

Codecov Report

❌ Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.13%. Comparing base (374b73b) to head (23ef2c3).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/auth/token.go 33.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2325      +/-   ##
==========================================
+ Coverage   54.11%   54.13%   +0.01%     
==========================================
  Files         239      239              
  Lines       23270    23273       +3     
==========================================
+ Hits        12592    12598       +6     
+ Misses       9508     9499       -9     
- Partials     1170     1176       +6     

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

Copy link
Contributor

@lujunsan lujunsan left a comment

Choose a reason for hiding this comment

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

LGTM

@JAORMX JAORMX merged commit 0083fd7 into main Oct 24, 2025
27 checks passed
@JAORMX JAORMX deleted the feature/oidc-env-secret-support-clean branch October 24, 2025 15:57
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