Skip to content

Commit

Permalink
feat: Adding the domain_hint as an optional field in OIDC configurati…
Browse files Browse the repository at this point in the history
…on (#18214)

* [18066] - Added DomainHint key in OIDCConfig struct

Signed-off-by: nikzayn <nikhilvaidyar1997@gmail.com>

* [18066] - Added DomainHint in options for grantType

Signed-off-by: nikzayn <nikhilvaidyar1997@gmail.com>

* [18066] - Auth0 readme.md --updated

Signed-off-by: nikzayn <nikhilvaidyar1997@gmail.com>

---------

Signed-off-by: nikzayn <nikhilvaidyar1997@gmail.com>
  • Loading branch information
nikzayn committed May 20, 2024
1 parent 4d61974 commit 9c8d652
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/argocd/commands/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/argoproj/argo-cd/v2/util/localconfig"
oidcutil "github.com/argoproj/argo-cd/v2/util/oidc"
"github.com/argoproj/argo-cd/v2/util/rand"
oidcconfig "github.com/argoproj/argo-cd/v2/util/settings"
)

// NewLoginCommand returns a new instance of `argocd login` command
Expand Down Expand Up @@ -306,6 +307,7 @@ func oauth2Login(
fmt.Printf("Opening browser for authentication\n")

var url string
var oidcconfig oidcconfig.OIDCConfig
grantType := oidcutil.InferGrantType(oidcConf)
opts := []oauth2.AuthCodeOption{oauth2.AccessTypeOffline}
if claimsRequested := oidcSettings.GetIDTokenClaims(); claimsRequested != nil {
Expand All @@ -316,6 +318,9 @@ func oauth2Login(
case oidcutil.GrantTypeAuthorizationCode:
opts = append(opts, oauth2.SetAuthURLParam("code_challenge", codeChallenge))
opts = append(opts, oauth2.SetAuthURLParam("code_challenge_method", "S256"))
if oidcconfig.DomainHint != "" {
opts = append(opts, oauth2.SetAuthURLParam("domain_hint", oidcconfig.DomainHint))
}
url = oauth2conf.AuthCodeURL(stateNonce, opts...)
case oidcutil.GrantTypeImplicit:
url, err = oidcutil.ImplicitFlowURL(oauth2conf, stateNonce, opts...)
Expand Down
1 change: 1 addition & 0 deletions docs/operator-manual/user-management/auth0.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ data:
issuer: https://<yourtenant>.<eu|us>.auth0.com/
clientID: <theClientId>
clientSecret: <theClientSecret>
domain_hint: <theDomainHint>
requestedScopes:
- openid
- profile
Expand Down
2 changes: 2 additions & 0 deletions util/settings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ func (o *oidcConfig) toExported() *OIDCConfig {
LogoutURL: o.LogoutURL,
RootCA: o.RootCA,
EnablePKCEAuthentication: o.EnablePKCEAuthentication,
DomainHint: o.DomainHint,
}
}

Expand All @@ -188,6 +189,7 @@ type OIDCConfig struct {
LogoutURL string `json:"logoutURL,omitempty"`
RootCA string `json:"rootCA,omitempty"`
EnablePKCEAuthentication bool `json:"enablePKCEAuthentication,omitempty"`
DomainHint string `json:"domainHint,omitempty"`
}

// DEPRECATED. Helm repository credentials are now managed using RepoCredentials
Expand Down

0 comments on commit 9c8d652

Please sign in to comment.