Skip to content

Commit

Permalink
Merge pull request #8 from superfly/hd
Browse files Browse the repository at this point in the history
Allow hd hint in oauth flow
  • Loading branch information
btoews authored Oct 27, 2023
2 parents 5436dd8 + 684427d commit b531999
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
22 changes: 21 additions & 1 deletion etc/ssokenizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,24 @@ identity_providers:
client_secret: "$HEROKU_CLIENT_SECRET"
return_url: "$HEROKU_STAGING_2_RETURN_URL"
scopes:
- "$HEROKU_SCOPES"
- "$HEROKU_SCOPES"

google_auth:
secret_auth:
bearer_digest: "$AUTH_DIGEST"
profile: google
client_id: "$GOOGLE_CLIENT_ID"
client_secret: "$GOOGLE_CLIENT_SECRET"
return_url: "$GOOGLE_AUTH_RETURN_URL"
scopes:
- "$GOOGLE_SCOPES"

github_auth:
secret_auth:
bearer_digest: "$AUTH_DIGEST"
profile: github
client_id: "$GITHUB_CLIENT_ID"
client_secret: "$GITHUB_CLIENT_SECRET"
return_url: "$GITHUB_AUTH_RETURN_URL"
scopes:
- "$GITHUB_SCOPES"
9 changes: 8 additions & 1 deletion oauth2/oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,14 @@ func (p *provider) handleStart(w http.ResponseWriter, r *http.Request) {
defer getLog(r).WithField("status", http.StatusFound).Info()

tr := ssokenizer.GetTransaction(r)
http.Redirect(w, r, p.config(r).AuthCodeURL(tr.Nonce, oauth2.AccessTypeOffline), http.StatusFound)

opts := []oauth2.AuthCodeOption{oauth2.AccessTypeOffline}

if hd := r.URL.Query().Get("hd"); hd != "" {
opts = append(opts, oauth2.SetAuthURLParam("hd", hd))
}

http.Redirect(w, r, p.config(r).AuthCodeURL(tr.Nonce, opts...), http.StatusFound)
}

func (p *provider) handleCallback(w http.ResponseWriter, r *http.Request) {
Expand Down

0 comments on commit b531999

Please sign in to comment.