allow customizing OICD scopes

This commit is contained in:
yusing 2025-01-13 08:30:46 +08:00
parent 76fe5345d8
commit 81d96394b9
3 changed files with 6 additions and 2 deletions

View file

@ -20,6 +20,8 @@ GODOXY_API_PASSWORD=password
# GODOXY_OIDC_CLIENT_SECRET=your-client-secret
# Keep /api/auth/callback as the redirect URL, change the domain to match your setup.
# GODOXY_OIDC_REDIRECT_URL=https://your-domain/api/auth/callback
# Comma-separated list of scopes
# GODOXY_OIDC_SCOPES=openid, profile, email
# Proxy listening address
GODOXY_HTTP_ADDR=:80
@ -32,4 +34,4 @@ GODOXY_API_ADDR=127.0.0.1:8888
#GODOXY_PROMETHEUS_ADDR=:8889
# Debug mode
GODOXY_DEBUG=false
GODOXY_DEBUG=false

View file

@ -9,6 +9,7 @@ import (
U "github.com/yusing/go-proxy/internal/api/v1/utils"
"github.com/yusing/go-proxy/internal/common"
E "github.com/yusing/go-proxy/internal/error"
"github.com/yusing/go-proxy/internal/utils/strutils"
"golang.org/x/oauth2"
)
@ -39,7 +40,7 @@ func InitOIDC(issuerURL, clientID, clientSecret, redirectURL string) error {
ClientSecret: clientSecret,
RedirectURL: redirectURL,
Endpoint: provider.Endpoint(),
Scopes: []string{oidc.ScopeOpenID, "profile", "email"},
Scopes: strutils.CommaSeperatedList(common.OIDCScopes),
}
return nil

View file

@ -50,6 +50,7 @@ var (
OIDCClientID = GetEnvString("OIDC_CLIENT_ID", "")
OIDCClientSecret = GetEnvString("OIDC_CLIENT_SECRET", "")
OIDCRedirectURL = GetEnvString("OIDC_REDIRECT_URL", "")
OIDCScopes = GetEnvString("OIDC_SCOPES", "openid, profile, email")
)
func GetEnv[T any](key string, defaultValue T, parser func(string) (T, error)) T {