This commit is contained in:
Feng Lee 2015-05-12 22:39:27 +08:00
parent ebf04c86d4
commit e93f4cf077
4 changed files with 13 additions and 13 deletions

View File

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

View File

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

View File

@ -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".

View File

@ -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}, []} }.