Commit bb71eebf authored by Taegyun Kim's avatar Taegyun Kim

template 기반으로 수정

parent 86705207
[
{emqx_auth_anonymous, []}
].
{deps,[]}.
{profiles,
[{test,
[{deps,[]}]
}
]}.
{erl_opts, [warn_unused_vars,
warn_shadow_vars,
warn_unused_import,
warn_obsolete_guard,
debug_info,
{parse_transform}]}.
{xref_checks, [undefined_function_calls, undefined_functions,
locals_not_used, deprecated_function_calls,
warnings_as_errors, deprecated_functions]}.
{cover_enabled, true}.
{cover_opts, [verbose]}.
{cover_export_enabled, true}.
{deps, []}.
{erl_opts, [debug_info]}.
......@@ -2,7 +2,7 @@
[{description, "EMQ X Authentication for anonymous"},
{vsn, "git"},
{modules, []},
{registered, []},
{registered, [emqx_auth_anonymous_sup]},
{applications, [kernel,stdlib]},
{mod, {emqx_auth_anonymous_app,[]}},
{env, []},
......
-module(emqx_auth_anonymous).
-export([check/2]).
-include_lib("emqx/include/emqx.hrl").
check(#{username := Username, password := Password}, AuthResult) ->
-export([ load/0, unload/0 ]).
-export([ on_client_authenticate/2 ]).
load() ->
emqx:hook('client.authenticate', {?MODULE, on_client_authenticate, []}).
on_client_authenticate(#{username := Username, password := Password}, AuthResult) ->
io:format("username: ~w, password: ~w~n", [Username, Password]),
{stop, AuthResult#{auth_result => success, anonymous => false}}.
{ok, AuthResult}.
unload() ->
emqx:unhook('client.authenticate', {?MODULE, on_client_authenticate}).
-module(emqx_auth_anonymous_app).
-behaviour(application).
-behaviour(supervisor).
-emqx_plugin(?MODULE).
-export([start/2, stop/1]).
-export([init/1]).
-export([ start/2, stop/1 ]).
start(_Type, _Args) ->
emqx:hook('client.authenticate', fun emqx_auth_anonymous:check/2),
supervisor:start_link({local, ?MODULE}, ?MODULE, []).
start(_StartType, _StartArgs) ->
{ok, Sup} = emqx_auth_anonymous_sub:start_link(),
emqx_plugin_template:load(),
{ok, Sup}.
stop(_State) ->
emqx:unhook('client.authenticate', fun emqx_auth_anonymous:check/2).
%%--------------------------------------------------------------------
init([]) ->
{ok, { {one_for_all, 1, 10}, []} }.
emqx_plugin_template:unload().
-module(emqx_auth_anonymous_sub).
-behaviour(supervisor).
-export([start_link/0]).
-export([init/1]).
start_link() ->
supervisor:start_link({local, ?MODULE}, ?MODULE, []).
init([]) ->
{ok, { {one_for_all, 0, 1}, []} }.
-module(emqx_auth_anonymous_SUITE).
-compile(export_all).
all() -> [].
groups() -> [].
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment