Merge pull request #11689 from JimMoen/0926-fix-sso-redirect-header

fix: lower sso saml redirect http header
This commit is contained in:
JianBo He 2023-09-27 08:35:43 +08:00 committed by GitHub
commit 1f8985d09e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -16,7 +16,7 @@ endif
# Dashboard version
# from https://github.com/emqx/emqx-dashboard5
export EMQX_DASHBOARD_VERSION ?= v1.4.1
export EMQX_EE_DASHBOARD_VERSION ?= e1.2.1
export EMQX_EE_DASHBOARD_VERSION ?= e1.3.0-beta.6
# `:=` should be used here, otherwise the `$(shell ...)` will be executed every time when the variable is used
# In make 4.4+, for backward-compatibility the value from the original environment is used.

View File

@ -29,7 +29,11 @@
-dialyzer({nowarn_function, do_create/1}).
-define(RESPHEADERS, #{<<"Cache-Control">> => <<"no-cache">>, <<"Pragma">> => <<"no-cache">>}).
-define(RESPHEADERS, #{
<<"cache-control">> => <<"no-cache">>,
<<"pragma">> => <<"no-cache">>,
<<"content-type">> => <<"text/plain">>
}).
-define(REDIRECT_BODY, <<"Redirecting...">>).
-define(DIR, <<"saml_sp_certs">>).
@ -129,7 +133,7 @@ login(
Html = esaml_binding:encode_http_post(IDP, SignedXml, <<>>),
{200, ?RESPHEADERS, Html};
false ->
{302, ?RESPHEADERS#{<<"Location">> => Target}, ?REDIRECT_BODY}
{302, ?RESPHEADERS#{<<"location">> => Target}, ?REDIRECT_BODY}
end,
{redirect, Redirect}.
@ -209,7 +213,7 @@ gen_redirect_response(DashboardAddr, Username) ->
case ensure_user_exists(Username) of
{ok, Role, Token} ->
Target = login_redirect_target(DashboardAddr, Username, Role, Token),
{redirect, {302, ?RESPHEADERS#{<<"Location">> => Target}, ?REDIRECT_BODY}};
{redirect, {302, ?RESPHEADERS#{<<"location">> => Target}, ?REDIRECT_BODY}};
{error, Reason} ->
{error, Reason}
end.