Skip to content
This repository has been archived by the owner on Dec 7, 2020. It is now read-only.

[KEYCLOAK-11499] Add idp-hint as a configuration option #495

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ type Resource struct {

// Config is the configuration for the proxy
type Config struct {
// IdpHint
IdpHint string `json:"idp-hint" yaml:"idp-hint" usage:"idp hint name configuration" env:"IDP_HINT"`
// ConfigFile is the binding interface
ConfigFile string `json:"config" yaml:"config" usage:"path the a configuration file" env:"CONFIG_FILE"`
// Listen is the binding interface
Expand Down
6 changes: 6 additions & 0 deletions handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ func (r *oauthProxy) oauthAuthorizationHandler(w http.ResponseWriter, req *http.
}

authURL := client.AuthCodeURL(req.URL.Query().Get("state"), accessType, "")
// idp_hint config
idpHint := r.config.IdpHint
if idpHint != "" {
authURL += "&kc_idp_hint=" + idpHint

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could there sometimes be other url parameters already in authURL? I am thinking "&" vs "?"
If that is never a possibility please disregard, otherwise I suggest adding some pre-inspection of authURL before appending.

}

r.log.Debug("incoming authorization request from client address",
zap.String("access_type", accessType),
zap.String("auth_url", authURL),
Expand Down