Skip to content

Commit b024ce1

Browse files
tombrkbgentry
authored andcommitted
google: allow to specify suggested domain
As per the Google OIDC docs, the `hd` parameter may be used to suggest the domain the user may login with: https://developers.google.com/identity/protocols/oauth2/openid-connect#hd-param In effect, the Google account chooser only displays accounts with that very domain, which simplifies the process for users with very long account lists.
1 parent c8d4002 commit b024ce1

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

internal/provider/google.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ type Google struct {
1414
ClientSecret string `long:"client-secret" env:"CLIENT_SECRET" description:"Client Secret" json:"-"`
1515
Scope string
1616
Prompt string `long:"prompt" env:"PROMPT" default:"select_account" description:"Space separated list of OpenID prompt options"`
17+
EmailDomain string `long:"email-domain" env:"EMAIL_DOMAIN" description:"Email domain the user is suggested to login with"`
1718

1819
LoginURL *url.URL
1920
TokenURL *url.URL
@@ -61,6 +62,9 @@ func (g *Google) GetLoginURL(redirectURI, state string) string {
6162
if g.Prompt != "" {
6263
q.Set("prompt", g.Prompt)
6364
}
65+
if g.EmailDomain != "" {
66+
q.Set("hd", g.EmailDomain)
67+
}
6468
q.Set("redirect_uri", redirectURI)
6569
q.Set("state", state)
6670

0 commit comments

Comments
 (0)