chore: fix bugs
This commit is contained in:
parent
47badc3181
commit
4a26f63bd6
|
@ -107,8 +107,8 @@ create(
|
||||||
%% certificate = Cert,
|
%% certificate = Cert,
|
||||||
sp_sign_requests = SignRequest,
|
sp_sign_requests = SignRequest,
|
||||||
trusted_fingerprints = [],
|
trusted_fingerprints = [],
|
||||||
consume_uri = BaseURL ++ "/sso_saml/acs",
|
consume_uri = BaseURL ++ "/sso/saml/acs",
|
||||||
metadata_uri = BaseURL ++ "/sso_saml/metadata",
|
metadata_uri = BaseURL ++ "/sso/saml/metadata",
|
||||||
org = #esaml_org{
|
org = #esaml_org{
|
||||||
name = "EMQX Team",
|
name = "EMQX Team",
|
||||||
displayname = "EMQX Dashboard",
|
displayname = "EMQX Dashboard",
|
||||||
|
@ -139,17 +139,14 @@ login(_Req, #{sp := SP, idp_meta := #esaml_idp_metadata{login_location = IDP}} =
|
||||||
Target = esaml_binding:encode_http_redirect(IDP, SignedXml, <<>>),
|
Target = esaml_binding:encode_http_redirect(IDP, SignedXml, <<>>),
|
||||||
%% TODO: _Req acutally is HTTP request body, not fully request
|
%% TODO: _Req acutally is HTTP request body, not fully request
|
||||||
RedirectFun = fun(Headers) ->
|
RedirectFun = fun(Headers) ->
|
||||||
|
RespHeaders = #{<<"Cache-Control">> => <<"no-cache">>, <<"Pragma">> => <<"no-cache">>},
|
||||||
case is_msie(Headers) of
|
case is_msie(Headers) of
|
||||||
true ->
|
true ->
|
||||||
Html = esaml_binding:encode_http_post(IDP, SignedXml, <<>>),
|
Html = esaml_binding:encode_http_post(IDP, SignedXml, <<>>),
|
||||||
{200,
|
{200, RespHeaders, Html};
|
||||||
[
|
|
||||||
{<<"Cache-Control">>, <<"no-cache">>},
|
|
||||||
{<<"Pragma">>, <<"no-cache">>}
|
|
||||||
],
|
|
||||||
Html};
|
|
||||||
false ->
|
false ->
|
||||||
{302, redirect_header(Target), <<"Redirecting...">>}
|
RespHeaders1 = RespHeaders#{<<"Location">> => Target},
|
||||||
|
{302, RespHeaders1, <<"Redirecting...">>}
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
{redirect, RedirectFun}.
|
{redirect, RedirectFun}.
|
||||||
|
@ -178,13 +175,6 @@ is_msie(Headers) ->
|
||||||
UA = maps:get(<<"user-agent">>, Headers, <<"">>),
|
UA = maps:get(<<"user-agent">>, Headers, <<"">>),
|
||||||
not (binary:match(UA, <<"MSIE">>) =:= nomatch).
|
not (binary:match(UA, <<"MSIE">>) =:= nomatch).
|
||||||
|
|
||||||
redirect_header(TargetUrl) ->
|
|
||||||
[
|
|
||||||
{<<"Cache-Control">>, <<"no-cache">>},
|
|
||||||
{<<"Pragma">>, <<"no-cache">>},
|
|
||||||
{<<"Location">>, TargetUrl}
|
|
||||||
].
|
|
||||||
|
|
||||||
%% TODO: unify with emqx_dashboard_sso_manager:ensure_user_exists/1
|
%% TODO: unify with emqx_dashboard_sso_manager:ensure_user_exists/1
|
||||||
ensure_user_exists(Username) ->
|
ensure_user_exists(Username) ->
|
||||||
case emqx_dashboard_admin:lookup_user(saml, Username) of
|
case emqx_dashboard_admin:lookup_user(saml, Username) of
|
||||||
|
|
Loading…
Reference in New Issue