Commit 453a0f09 authored by Taegyun Kim's avatar Taegyun Kim

git

parents
.eunit
deps
*.o
*.beam
*.plt
erl_crash.dump
ebin
rel/example_project
.concrete/DEV_MODE
.rebar
.erlang.mk/
emqx_auth_anonymous.d
data/
_build/
.DS_Store
cover/
ct.coverdata
eunit.coverdata
logs/
test/ct.cover.spec
rebar.lock
rebar3.crashdump
erlang.mk
.*.swp
.rebar3/
etc/emqx_auth_anonymous.conf.rendered
Copyright (c) 2020 T.SooranKim
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
\ No newline at end of file
## shallow clone for speed
REBAR_GIT_CLONE_OPTIONS += --depth 1
export REBAR_GIT_CLONE_OPTIONS
REBAR = rebar3
all: compile
compile:
$(REBAR) compile
ct: compile
$(REBAR) as test ct -v
eunit: compile
$(REBAR) as test eunit
xref:
$(REBAR) xref
cover:
$(REBAR) cover
clean: distclean
distclean:
@rm -rf _build
@rm -f data/app.*.config data/vm.*.args rebar.lock
emqx_auth_anonymous
==================
EMQ X Authentication for anonymous
\ No newline at end of file
{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}.
%%-*- mode: erlang -*-
%% emqx_management rebar.config.script
CONFIG1 = case os:getenv("TRAVIS") of
"true" ->
JobId = os:getenv("TRAVIS_JOB_ID"),
[{coveralls_service_job_id, JobId},
{coveralls_coverdata, "_build/test/cover/*.coverdata"},
{coveralls_service_name , "travis-ci"} | CONFIG];
_ ->
CONFIG
end,
DEPS = case lists:keyfind(deps, 1, CONFIG1) of
{_, Deps} -> Deps;
_ -> []
end,
CUR_BRANCH = case os:getenv("GITHUB_RUN_ID") of
false ->
os:cmd("git branch | grep -e '^*' | cut -d' ' -f 2") -- "\n";
_ ->
re:replace(os:getenv("GITHUB_REF"), ".*/", "", [global, {return ,list}])
end,
MATCH_BRANCH = fun (BranchName) ->
case re:run(BranchName, "^release|develop|master", [{capture, none}]) of
match -> BranchName;
_ -> case re:run(BranchName, "^[v]?[0-9]\.[0-9]\.([0-9]|(rc|beta|alpha)\.[0-9])", [{capture, none}]) of
match -> BranchName;
_ -> "develop"
end
end
end,
BRANCH = MATCH_BRANCH(CUR_BRANCH),
UrlPrefix = "https://github.com/emqx/",
EMQX_DEP = {emqx, {git, UrlPrefix ++ "emqx", {branch, BRANCH}}},
EMQX_MGMT_DEP = {emqx_management, {git, UrlPrefix ++ "emqx-management", {branch, BRANCH}}},
NewDeps = [EMQX_DEP,EMQX_MGMT_DEP | DEPS],
CONFIG2 = lists:keystore(deps, 1, CONFIG1, {deps, NewDeps}),
CONFIG2.
{application, emqx_auth_anonymous,
[{description, "EMQ X Authentication for anonymous"},
{vsn, "git"},
{modules, []},
{registered, [emqx_auth_anonymous_app]},
{applications, [kernel,stdlib]},
{mod, {emqx_auth_anonymous_app,[]}},
{env, []},
{licenses, ["MIT License"]},
{maintainers, ["Sooran Kim <t.soorankim@gmail.com>"]},
{links, [{"Homepage", "https://kim.sr/"},
{"Github", "https://github.com/TsooranKim/emqx-auth-anonymous"}
]}
]}.
%%-*- mode: erlang -*-
%% .app.src.script
RemoveLeadingV =
fun(Tag) ->
case re:run(Tag, "v\[0-9\]+\.\[0-9\]+\.*") of
nomatch ->
Tag;
{match, _} ->
%% if it is a version number prefixed by 'v' then remove the 'v'
"v" ++ Vsn = Tag,
Vsn
end
end,
case os:getenv("EMQX_DEPS_DEFAULT_VSN") of
false -> CONFIG; % env var not defined
[] -> CONFIG; % env var set to empty string
Tag ->
[begin
AppConf0 = lists:keystore(vsn, 1, AppConf, {vsn, RemoveLeadingV(Tag)}),
{application, App, AppConf0}
end || Conf = {application, App, AppConf} <- CONFIG]
end.
-module(emqx_auth_anonymous).
-export([check/2]).
check(#{username := Username, password := Password}, AuthResult) ->
io:format("username: ~w, password: ~w~n", [Username, Password]),
{stop, AuthResult#{auth_result => success, anonymous => false}}.
-module(emqx_auth_anonymous_app).
-behaviour(application).
-behaviour(supervisor).
-emqx_plugin(?MODULE).
-export([start/2, stop/1]).
-export([init/1]).
start(_Type, _Args) ->
emqx:hook('client.authenticate', fun emqx_auth_anonymous:check/2),
supervisor:start_link({local, ?MODULE}, ?MODULE, []).
stop(_State) ->
emqx:unhook('client.authenticate', fun emqx_auth_anonymous:check/2).
%%--------------------------------------------------------------------
init([]) ->
{ok, { {one_for_all, 1, 10}, []} }.
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