LDAP Auth Plugin

This commit is contained in:
Feng Lee 2015-05-11 16:40:10 +08:00
commit 4a8d194582
8 changed files with 95 additions and 2 deletions

4
TODO
View File

@ -6,6 +6,10 @@ v0.9.0-alpha (2015-05-30)
v0.8.0-alpha (2015-05-10) v0.8.0-alpha (2015-05-10)
------------------------- -------------------------
Presence Management....
Force Subscriptions...
Documents... Documents...
MySQL Auth MySQL Auth

View File

@ -1,12 +1,23 @@
{application, emqttd_auth_ldap, {application, emqttd_auth_ldap,
[ [
<<<<<<< HEAD
{description, "emqttd LDA Authentication Plugin"}, {description, "emqttd LDA Authentication Plugin"},
{vsn, "1.0"}, {vsn, "1.0"},
=======
{description, ""},
{vsn, "1"},
>>>>>>> c6e92388798302ae3b44286f444505d1c385aba7
{registered, []}, {registered, []},
{applications, [ {applications, [
kernel, kernel,
stdlib stdlib
]}, ]},
<<<<<<< HEAD
{mod, {emqttd_auth_ldap_app, []}}, {mod, {emqttd_auth_ldap_app, []}},
{env, []} {env, []}
]}. ]}.
=======
{mod, { emqttd_auth_ldap_app, []}},
{env, []}
]}.
>>>>>>> c6e92388798302ae3b44286f444505d1c385aba7

View File

@ -20,7 +20,11 @@
%%% SOFTWARE. %%% SOFTWARE.
%%%----------------------------------------------------------------------------- %%%-----------------------------------------------------------------------------
%%% @doc %%% @doc
<<<<<<< HEAD
%%% LDAP Authentication Module. %%% LDAP Authentication Module.
=======
%%% LDAP authentication module.
>>>>>>> c6e92388798302ae3b44286f444505d1c385aba7
%%% %%%
%%% @end %%% @end
%%%----------------------------------------------------------------------------- %%%-----------------------------------------------------------------------------
@ -34,6 +38,7 @@
-export([init/1, check/3, description/0]). -export([init/1, check/3, description/0]).
<<<<<<< HEAD
-record(state, {servers, user_dn, options}). -record(state, {servers, user_dn, options}).
init(Opts) -> init(Opts) ->
@ -86,4 +91,11 @@ fill(Username, UserDn) ->
fun("$u") -> Username; fun("$u") -> Username;
(S) -> S (S) -> S
end, string:tokens(UserDn, ",="))). end, string:tokens(UserDn, ",="))).
=======
init(Opts) -> {ok, Opts}.
check(_Client, _Password, _Opts) -> ingore.
description() -> "LDAP authentication module".
>>>>>>> c6e92388798302ae3b44286f444505d1c385aba7

View File

@ -1,3 +1,4 @@
<<<<<<< HEAD
%%%----------------------------------------------------------------------------- %%%-----------------------------------------------------------------------------
%%% Copyright (c) 2012-2015 eMQTT.IO, All Rights Reserved. %%% Copyright (c) 2012-2015 eMQTT.IO, All Rights Reserved.
%%% %%%
@ -56,3 +57,25 @@ stop(_State) ->
init([]) -> init([]) ->
{ok, { {one_for_one, 5, 10}, []} }. {ok, { {one_for_one, 5, 10}, []} }.
=======
-module(emqttd_auth_ldap_app).
-behaviour(application).
%% Application callbacks
-export([start/2, stop/1]).
%% ===================================================================
%% Application callbacks
%% ===================================================================
start(_StartType, _StartArgs) ->
{ok, Sup} = emqttd_auth_ldap_sup:start_link(),
Env = application:get_all_env(),
emqttd_access_control:register_mod(auth, emqttd_auth_ldap, Env),
{ok, Sup}.
stop(_State) ->
emqttd_access_control:unregister_mod(auth, emqttd_auth_ldap),
ok.
>>>>>>> c6e92388798302ae3b44286f444505d1c385aba7

View File

@ -0,0 +1,27 @@
-module(emqttd_auth_ldap_sup).
-behaviour(supervisor).
%% API
-export([start_link/0]).
%% Supervisor callbacks
-export([init/1]).
%% Helper macro for declaring children of supervisor
-define(CHILD(I, Type), {I, {I, start_link, []}, permanent, 5000, Type, [I]}).
%% ===================================================================
%% API functions
%% ===================================================================
start_link() ->
supervisor:start_link({local, ?MODULE}, ?MODULE, []).
%% ===================================================================
%% Supervisor callbacks
%% ===================================================================
init([]) ->
{ok, { {one_for_one, 5, 10}, []} }.

View File

@ -28,6 +28,11 @@
-author("Feng Lee <feng@emqtt.io>"). -author("Feng Lee <feng@emqtt.io>").
-export([handle_request/1]).
%%TODO... %%TODO...
handle_request(Req) ->
Req:ok("hello!").

View File

@ -10,7 +10,18 @@
%% =================================================================== %% ===================================================================
start(_StartType, _StartArgs) -> start(_StartType, _StartArgs) ->
emqttd_dashboard_sup:start_link(). {ok, Sup} = emqttd_dashboard_sup:start_link(),
open_listener(application:get_env(listener)),
{ok, Sup}.
stop(_State) -> stop(_State) ->
ok. ok.
%% open http port
open_listener({_Http, Port, Options}) ->
MFArgs = {emqttd_dashboard, handle_request, []},
mochiweb:start_http(Port, Options, MFArgs).
close_listener(Port) ->
mochiweb:stop_http(Port).

View File

@ -14,7 +14,7 @@
% %
% {emqttd_dashboard, [ % {emqttd_dashboard, [
% {listener, % {listener,
% {http, 8080, [ % {http, 18083, [
% {acceptors, 4}, % {acceptors, 4},
% {max_clients, 512}]}} % {max_clients, 512}]}}
% ]} % ]}