Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional callback versions to auth_on_register hooks #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/auth_on_register_hook.erl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@
| {ok, [reg_modifiers()]}
| {error, invalid_credentials | any()}
| next.
%% optional callback including Opts map, for easier future extensions
-callback auth_on_register(Peer :: peer(),
SubscriberId :: subscriber_id(),
UserName :: username(),
Password :: password(),
CleanSession :: flag(),
Opts :: map()) -> ok
| {ok, [reg_modifiers()]}
| {error, invalid_credentials | any()}
| next.
-optional_callbacks([auth_on_register/6]).

-type reg_modifiers() ::
%% Change the mountpoint for the session.
{mountpoint, mountpoint()}
Expand Down
16 changes: 16 additions & 0 deletions src/auth_on_register_m5_hook.erl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,22 @@
{error, atom()} | %% will be turned into ?NOT_AUTHORIZED
next.

%% optional callback including Opts map, for easier future extensions
-callback auth_on_register_m5(Peer :: peer(),
SubscriberId :: subscriber_id(),
UserName :: username(),
Password :: password(),
CleanStart :: flag(),
Properties :: reg_properties(),
Opts :: map()) ->
ok |
{ok, reg_modifiers()} |
{error, #{reason_code => err_reason_code_name()}} |
{error, atom()} | %% will be turned into ?NOT_AUTHORIZED
next.

-optional_callbacks([auth_on_register_m5/7]).

-type reg_properties() ::
#{
p_session_expiry_interval => seconds(),
Expand Down