Skip to content

Commit

Permalink
Add option to pass kc_idp_hint
Browse files Browse the repository at this point in the history
This is currently not working, but can be used later
  • Loading branch information
matti-lamppu committed Nov 19, 2024
1 parent 14e7edc commit 4598cef
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 10 additions & 1 deletion config/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,18 @@ def get_user(self, user_id: Any = None) -> User | None:

def auth_params(self, state: str | None = None) -> dict[str, str]:
params = super().auth_params(state)
lang = self.strategy.request_data().get("ui_locales")

request_data = self.strategy.request_data()

# Parameters from `tilavarauspalvelu.api.helauth.views.login_view`.
lang = request_data.get("ui_locales")
login_method_hint = request_data.get("kc_idp_hint")

if lang:
params["ui_locales"] = lang
if login_method_hint:
params["kc_idp_hint"] = login_method_hint

return params

def get_end_session_url(self, request: WSGIRequest, id_token: str) -> str | None:
Expand Down
5 changes: 5 additions & 0 deletions tilavarauspalvelu/api/helauth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ def login_view(request: WSGIRequest) -> HttpResponseRedirect:
if lang:
url = update_query_params(url, ui_locales=lang)

login_method_hint: str | None = request.GET.get("ui")
if login_method_hint == "customer":
# For `kc_idp_hint`, see: https://www.keycloak.org/docs/latest/server_admin/#_client_suggested_idp
url = update_query_params(url, kc_idp_hint="suomi_fi")

return HttpResponseRedirect(url)


Expand Down

0 comments on commit 4598cef

Please sign in to comment.