Skip to content

Commit 0083fd7

Browse files
JAORMXclaude
andauthored
Add environment variable support for OIDC client secret (#2325)
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>
1 parent 374b73b commit 0083fd7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pkg/auth/token.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"io"
1010
"net/http"
1111
"net/url"
12+
"os"
1213
"strconv"
1314
"strings"
1415
"sync"
@@ -541,6 +542,14 @@ func NewTokenValidator(ctx context.Context, config TokenValidatorConfig) (*Token
541542
registry.AddProvider(NewGoogleProvider(config.IntrospectionURL))
542543
}
543544

545+
// Load client secret from environment variable if not provided in config
546+
// This allows secrets to be injected via Kubernetes Secret references
547+
if config.ClientSecret == "" {
548+
if envSecret := os.Getenv("TOOLHIVE_OIDC_CLIENT_SECRET"); envSecret != "" {
549+
config.ClientSecret = envSecret
550+
}
551+
}
552+
544553
// Add RFC7662 provider with auth if configured
545554
if config.ClientID != "" || config.ClientSecret != "" {
546555
rfc7662Provider, err := NewRFC7662ProviderWithAuth(

0 commit comments

Comments
 (0)