Skip to content

Commit 56da8bf

Browse files
authored
Remote server support (#1423)
1 parent 2c866e4 commit 56da8bf

34 files changed

+2045
-377
lines changed

cmd/thv/app/auth_flags.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package app
2+
3+
import (
4+
"time"
5+
6+
"github.com/spf13/cobra"
7+
)
8+
9+
// RemoteAuthFlags holds the common remote authentication configuration
10+
type RemoteAuthFlags struct {
11+
EnableRemoteAuth bool
12+
RemoteAuthClientID string
13+
RemoteAuthClientSecret string
14+
RemoteAuthClientSecretFile string
15+
RemoteAuthScopes []string
16+
RemoteAuthSkipBrowser bool
17+
RemoteAuthTimeout time.Duration
18+
RemoteAuthCallbackPort int
19+
RemoteAuthIssuer string
20+
RemoteAuthAuthorizeURL string
21+
RemoteAuthTokenURL string
22+
}
23+
24+
// AddRemoteAuthFlags adds the common remote authentication flags to a command
25+
func AddRemoteAuthFlags(cmd *cobra.Command, config *RemoteAuthFlags) {
26+
cmd.Flags().BoolVar(&config.EnableRemoteAuth, "remote-auth", false,
27+
"Enable OAuth/OIDC authentication to remote MCP server")
28+
cmd.Flags().StringVar(&config.RemoteAuthIssuer, "remote-auth-issuer", "",
29+
"OAuth/OIDC issuer URL for remote server authentication (e.g., https://accounts.google.com)")
30+
cmd.Flags().StringVar(&config.RemoteAuthClientID, "remote-auth-client-id", "",
31+
"OAuth client ID for remote server authentication")
32+
cmd.Flags().StringVar(&config.RemoteAuthClientSecret, "remote-auth-client-secret", "",
33+
"OAuth client secret for remote server authentication (optional for PKCE)")
34+
cmd.Flags().StringVar(&config.RemoteAuthClientSecretFile, "remote-auth-client-secret-file", "",
35+
"Path to file containing OAuth client secret (alternative to --remote-auth-client-secret)")
36+
cmd.Flags().StringSliceVar(&config.RemoteAuthScopes, "remote-auth-scopes", []string{},
37+
"OAuth scopes to request for remote server authentication (defaults: OIDC uses 'openid,profile,email')")
38+
cmd.Flags().BoolVar(&config.RemoteAuthSkipBrowser, "remote-auth-skip-browser", false,
39+
"Skip opening browser for remote server OAuth flow")
40+
cmd.Flags().DurationVar(&config.RemoteAuthTimeout, "remote-auth-timeout", 30*time.Second,
41+
"Timeout for OAuth authentication flow (e.g., 30s, 1m, 2m30s)")
42+
cmd.Flags().IntVar(&config.RemoteAuthCallbackPort, "remote-auth-callback-port", 8666,
43+
"Port for OAuth callback server during remote authentication")
44+
cmd.Flags().StringVar(&config.RemoteAuthAuthorizeURL, "remote-auth-authorize-url", "",
45+
"OAuth authorization endpoint URL (alternative to --remote-auth-issuer for non-OIDC OAuth)")
46+
cmd.Flags().StringVar(&config.RemoteAuthTokenURL, "remote-auth-token-url", "",
47+
"OAuth token endpoint URL (alternative to --remote-auth-issuer for non-OIDC OAuth)")
48+
}

0 commit comments

Comments
 (0)