Feng Lee 10 лет назад
Родитель
Сommit
e93f4cf077

+ 0 - 2
plugins/emqttd_auth_ldap/README.md

@@ -1,4 +1,3 @@
-
 ## Overview
 
 Authentication with LDAP.
@@ -16,7 +15,6 @@ Authentication with LDAP.
         {"certfile", "ssl.crt"},
         {"keyfile", "ssl.key"}]}
  ]}
-
 ```
 
 ## Load Plugin

+ 1 - 1
plugins/emqttd_auth_ldap/src/emqttd_auth_ldap.app.src

@@ -1,6 +1,6 @@
 {application, emqttd_auth_ldap,
  [
-  {description, "emqttd LDA Authentication Plugin"},
+  {description, "emqttd LDAP Authentication Plugin"},
   {vsn, "1.0"},
   {registered, []},
   {applications, [

+ 11 - 8
plugins/emqttd_auth_ldap/src/emqttd_auth_ldap.erl

@@ -30,6 +30,8 @@
 
 -include_lib("emqttd/include/emqttd.hrl").
 
+-import(proplists, [get_value/2, get_value/3]).
+
 -behaviour(emqttd_auth_mod).
 
 -export([init/1, check/3, description/0]).
@@ -37,14 +39,14 @@
 -record(state, {servers, user_dn, options}).
 
 init(Opts) ->
-    Servers = proplists:get_value(servers, Opts, ["localhost"]),
-    Port = proplists:get_value(port, Opts, 389),
-    Timeout = proplists:get_value(timeout, Opts, 30),
-    UserDn = proplists:get_value(user_dn, Opts),
+    Servers = get_value(servers, Opts, ["localhost"]),
+    Port    = get_value(port, Opts, 389),
+    Timeout = get_value(timeout, Opts, 30),
+    UserDn  = get_value(user_dn, Opts),
     LdapOpts =
-    case proplists:get_value(ssl, Opts, false) of
+    case get_value(ssl, Opts, false) of
         true -> 
-            SslOpts = proplists:get_value(sslopts, Opts),
+            SslOpts = get_value(sslopts, Opts),
             [{port, Port}, {timeout, Timeout}, {sslopts, SslOpts}];
         false ->
             [{port, Port}, {timeout, Timeout}]
@@ -67,8 +69,6 @@ check(#mqtt_client{username = Username}, Password,
             {error, Reason}
     end.
 
-description() -> "LDAP Authentication Module".
-
 ldap_bind(LDAP, UserDn, Password) ->
     case catch eldap:simple_bind(LDAP, UserDn, Password) of
         ok ->
@@ -87,3 +87,6 @@ fill(Username, UserDn) ->
                 (S) -> S
             end, string:tokens(UserDn, ",="))).
 
+description() -> 
+    "LDAP Authentication Module".
+

+ 1 - 2
plugins/emqttd_auth_ldap/src/emqttd_auth_ldap_app.erl

@@ -20,7 +20,7 @@
 %%% SOFTWARE.
 %%%-----------------------------------------------------------------------------
 %%% @doc
-%%% LDAP Authentication APP.
+%%% LDAP Authentication Plugin.
 %%%
 %%% @end
 %%%-----------------------------------------------------------------------------
@@ -56,4 +56,3 @@ stop(_State) ->
 init([]) ->
     {ok, { {one_for_one, 5, 10}, []} }.
 
-