Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pkg/cmd/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func NewLoginCmd(ctx context.Context) *cobra.Command {
}
tenantCfg.CAFile = body
}

conf, err := config.Read(logger)
if err != nil {
return err
Expand All @@ -51,7 +52,7 @@ func NewLoginCmd(ctx context.Context) *cobra.Command {
cmd.Flags().StringVar(&tenantCfg.OIDC.ClientSecret, "oidc.client-secret", "", "The OIDC client secret, see https://tools.ietf.org/html/rfc6749#section-2.3.")
cmd.Flags().StringVar(&tenantCfg.OIDC.ClientID, "oidc.client-id", "", "The OIDC client ID, see https://tools.ietf.org/html/rfc6749#section-2.3.")
cmd.Flags().StringVar(&tenantCfg.OIDC.Audience, "oidc.audience", "", "The audience for whom the access token is intended, see https://openid.net/specs/openid-connect-core-1_0.html#IDToken.")
cmd.Flags().BoolVar(&tenantCfg.OIDC.OfflineAccess, "oidc.offline-access", true, "If set to false, oidc scope offline_access will not be requested, see https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest")
cmd.Flags().StringSliceVar(&tenantCfg.OIDC.Scopes, "oidc.scopes", nil, "OIDC scopes to request (default: openid,offline_access). See https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest")

cmd.Flags().BoolVar(&disableOIDCCheck, "disable.oidc-check", false, "If set to true, OIDC flags will not be checked while saving tenant details locally.")

Expand Down
26 changes: 13 additions & 13 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ type TenantConfig struct {
type OIDCConfig struct {
Token *oauth2.Token `json:"token"`

Audience string `json:"audience"`
ClientID string `json:"clientID"`
ClientSecret string `json:"clientSecret"`
IssuerURL string `json:"issuerURL"`
OfflineAccess bool `json:"offlineAccess"`
Audience string `json:"audience"`
ClientID string `json:"clientID"`
ClientSecret string `json:"clientSecret"`
IssuerURL string `json:"issuerURL"`
Scopes []string `json:"scopes,omitempty"`
}

// Client returns a OAuth2 HTTP client based on the configuration for a tenant.
Expand All @@ -93,10 +93,10 @@ func (t *TenantConfig) Client(ctx context.Context, logger log.Logger) (*http.Cli
return nil, fmt.Errorf("constructing oidc provider: %w", err)
}

scopes := []string{"openid"}

if t.OIDC.OfflineAccess {
scopes = append(scopes, "offline_access")
scopes := t.OIDC.Scopes
if len(scopes) == 0 {
// Default scopes if none provided
scopes = []string{"openid", "offline_access"}
}

ccc := clientcredentials.Config{
Expand Down Expand Up @@ -145,10 +145,10 @@ func (t *TenantConfig) Transport(ctx context.Context, logger log.Logger) (http.R
return nil, fmt.Errorf("constructing oidc provider: %w", err)
}

scopes := []string{"openid"}

if t.OIDC.OfflineAccess {
scopes = append(scopes, "offline_access")
scopes := t.OIDC.Scopes
if len(scopes) == 0 {
// Default scopes if none provided
scopes = []string{"openid", "offline_access"}
}

ccc := clientcredentials.Config{
Expand Down
Loading