feat: odic refine (#3202)

Co-authored-by: Matt Feury <mattfeury@gmail.com>
This commit is contained in:
0x7fff
2022-12-12 15:10:38 +08:00
committed by GitHub
parent 2f66dc3e99
commit af0b7939a7
4 changed files with 265 additions and 35 deletions

View File

@@ -18,7 +18,7 @@ import (
"context"
"fmt"
"github.com/coreos/go-oidc"
"github.com/coreos/go-oidc/v3/oidc"
"golang.org/x/oauth2/clientcredentials"
"github.com/fatedier/frp/pkg/msg"
@@ -103,17 +103,14 @@ func NewOidcAuthSetter(baseCfg BaseConfig, cfg OidcClientConfig) *OidcAuthProvid
eps[k] = []string{v}
}
// Previous versions hardcoded the scope to audience,
// so for backwards compatibility, use that if no scope is set
scope := cfg.OidcAudience
if cfg.OidcScope != "" {
scope = cfg.OidcScope
if cfg.OidcAudience != "" {
eps["audience"] = []string{cfg.OidcAudience}
}
tokenGenerator := &clientcredentials.Config{
ClientID: cfg.OidcClientID,
ClientSecret: cfg.OidcClientSecret,
Scopes: []string{scope},
Scopes: []string{cfg.OidcScope},
TokenURL: cfg.OidcTokenEndpointURL,
EndpointParams: eps,
}