Skip to content

Commit a1b4ed0

Browse files
JAORMXclaude
andauthored
Move OAuth secret management into pkg/auth/oauth (#2462)
Previously pkg/oauth/ contained only OAuth client secret management functions (ProcessOAuthClientSecret, StoreSecretInManager), which was confusing because it shared a similar name with pkg/auth/oauth/ which contains the actual OAuth/OIDC protocol implementation. This change: - Moves pkg/oauth/client_secret.go → pkg/auth/oauth/secrets.go - Updates 2 call sites: cmd/thv/app/run_flags.go, pkg/runner/config.go - Removes pkg/oauth/ directory entirely Benefits: - Clearer package structure (all OAuth code under pkg/auth/oauth/) - No more confusion between pkg/oauth and pkg/auth/oauth - Better separation: secrets.go for secret management, flow.go for OAuth protocol 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
1 parent 2d4af47 commit a1b4ed0

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

cmd/thv/app/run_flags.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/spf13/cobra"
99

1010
"github.com/stacklok/toolhive/pkg/auth"
11+
authoauth "github.com/stacklok/toolhive/pkg/auth/oauth"
1112
"github.com/stacklok/toolhive/pkg/authz"
1213
"github.com/stacklok/toolhive/pkg/cli"
1314
cfg "github.com/stacklok/toolhive/pkg/config"
@@ -17,7 +18,6 @@ import (
1718
"github.com/stacklok/toolhive/pkg/ignore"
1819
"github.com/stacklok/toolhive/pkg/logger"
1920
"github.com/stacklok/toolhive/pkg/networking"
20-
"github.com/stacklok/toolhive/pkg/oauth"
2121
"github.com/stacklok/toolhive/pkg/process"
2222
"github.com/stacklok/toolhive/pkg/registry"
2323
"github.com/stacklok/toolhive/pkg/runner"
@@ -854,5 +854,5 @@ func createTelemetryConfig(otelEndpoint string, otelEnablePrometheusMetricsPath
854854

855855
// processOAuthClientSecret processes an OAuth client secret, converting plain text to secret reference if needed
856856
func processOAuthClientSecret(clientSecret, workloadName string) (string, error) {
857-
return oauth.ProcessOAuthClientSecret(workloadName, clientSecret)
857+
return authoauth.ProcessOAuthClientSecret(workloadName, clientSecret)
858858
}

pkg/oauth/client_secret.go renamed to pkg/auth/oauth/secrets.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Package oauth contains the OAuth management logic for ToolHive.
1+
// Package oauth contains OAuth/OIDC protocol implementation for ToolHive.
22
package oauth
33

44
import (
File renamed without changes.

pkg/runner/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
"github.com/stacklok/toolhive/pkg/audit"
1212
"github.com/stacklok/toolhive/pkg/auth"
13+
authoauth "github.com/stacklok/toolhive/pkg/auth/oauth"
1314
"github.com/stacklok/toolhive/pkg/authz"
1415
"github.com/stacklok/toolhive/pkg/container"
1516
rt "github.com/stacklok/toolhive/pkg/container/runtime"
@@ -18,7 +19,6 @@ import (
1819
"github.com/stacklok/toolhive/pkg/labels"
1920
"github.com/stacklok/toolhive/pkg/logger"
2021
"github.com/stacklok/toolhive/pkg/networking"
21-
"github.com/stacklok/toolhive/pkg/oauth"
2222
"github.com/stacklok/toolhive/pkg/permissions"
2323
"github.com/stacklok/toolhive/pkg/registry"
2424
"github.com/stacklok/toolhive/pkg/secrets"
@@ -225,7 +225,7 @@ func migrateOAuthClientSecret(config *RunConfig) error {
225225
}
226226

227227
// The client secret is in plain text format - migrate it
228-
cliFormatSecret, err := oauth.ProcessOAuthClientSecret(config.Name, config.RemoteAuthConfig.ClientSecret)
228+
cliFormatSecret, err := authoauth.ProcessOAuthClientSecret(config.Name, config.RemoteAuthConfig.ClientSecret)
229229
if err != nil {
230230
return fmt.Errorf("failed to process OAuth client secret: %w", err)
231231
}

0 commit comments

Comments
 (0)