瀏覽代碼

chore: make dialyzer happy

JianBo He 2 年之前
父節點
當前提交
47badc3181

+ 1 - 1
apps/emqx_dashboard_sso/src/emqx_dashboard_sso.erl

@@ -39,7 +39,7 @@
     {ok, NewState :: state()} | {error, Reason :: term()}.
 -callback destroy(State :: state()) -> ok.
 -callback login(request(), State :: state()) ->
-    {ok, dashboard_user_role(), Token :: binary()} | {error, Reason :: term()}.
+    {ok, dashboard_user_role(), Token :: binary()} | {redirect, fun()} | {error, Reason :: term()}.
 
 %%------------------------------------------------------------------------------
 %% Callback Interface

+ 7 - 5
apps/emqx_dashboard_sso/src/emqx_dashboard_sso_saml.erl

@@ -12,20 +12,22 @@
 -behaviour(emqx_dashboard_sso).
 
 -export([
+    hocon_ref/0,
+    login_ref/0,
     fields/1,
     desc/1
 ]).
 
+%% emqx_dashboard_sso callbacks
 -export([
-    hocon_ref/0,
-    login_ref/0,
-    login/2,
     create/1,
     update/2,
     destroy/1
 ]).
 
--export([callback/2]).
+-export([login/2, callback/2]).
+
+-dialyzer({nowarn_function, create/1}).
 
 %%------------------------------------------------------------------------------
 %% Hocon Schema
@@ -156,7 +158,7 @@ callback(Req, #{sp := SP} = _State) ->
     case esaml_cowboy:validate_assertion(SP, fun esaml_util:check_dupe_ets/2, Req) of
         {ok, Assertion, _RelayState, _Req2} ->
             Subject = Assertion#esaml_assertion.subject,
-            Username = Subject#esaml_subject.name,
+            Username = iolist_to_binary(Subject#esaml_subject.name),
             ensure_user_exists(Username);
         {error, Reason0, _Req2} ->
             Reason = [