1 |
|
-module(ejabberd_auth_dummy). |
2 |
|
|
3 |
|
%% API |
4 |
|
-export([start/1, |
5 |
|
stop/1, |
6 |
|
config_spec/0, |
7 |
|
check_password/4, |
8 |
|
check_password/6, |
9 |
|
authorize/1, |
10 |
|
remove_domain/2, |
11 |
|
supported_features/0]). |
12 |
|
|
13 |
|
%% ejabberd_auth compatibility layer - not supported features |
14 |
|
-behaviour(mongoose_gen_auth). |
15 |
|
|
16 |
|
-export([set_password/4, |
17 |
|
try_register/4, |
18 |
|
get_password/3, |
19 |
|
get_password_s/3, |
20 |
|
does_user_exist/3, |
21 |
|
remove_user/3, |
22 |
|
supports_sasl_module/2, |
23 |
|
scram_passwords/0]). |
24 |
|
|
25 |
|
-ignore_xref([scram_passwords/0]). |
26 |
|
|
27 |
|
-include("mongoose.hrl"). |
28 |
|
-include("mongoose_config_spec.hrl"). |
29 |
|
|
30 |
|
%%%---------------------------------------------------------------------- |
31 |
|
%%% API |
32 |
|
%%%---------------------------------------------------------------------- |
33 |
|
|
34 |
|
-spec start(HostType :: mongooseim:host_type()) -> ok. |
35 |
|
start(_HostType) -> |
36 |
64 |
ok. |
37 |
|
|
38 |
|
-spec stop(HostType :: mongooseim:host_type()) -> ok. |
39 |
|
stop(_HostType) -> |
40 |
:-( |
ok. |
41 |
|
|
42 |
|
-spec config_spec() -> mongoose_config_spec:config_section(). |
43 |
|
config_spec() -> |
44 |
122 |
#section{ |
45 |
|
items = #{<<"base_time">> => #option{type = integer, |
46 |
|
validate = non_negative}, |
47 |
|
<<"variance">> => #option{type = integer, |
48 |
|
validate = positive}}, |
49 |
|
defaults = #{<<"base_time">> => 50, |
50 |
|
<<"variance">> => 450} |
51 |
|
}. |
52 |
|
|
53 |
|
authorize(Creds) -> |
54 |
9 |
HostType = mongoose_credentials:host_type(Creds), |
55 |
9 |
#{base_time := Base, |
56 |
|
variance := Variance} = mongoose_config:get_opt([{auth, HostType}, dummy]), |
57 |
9 |
timer:sleep(Base + rand:uniform(Variance)), |
58 |
9 |
{ok, mongoose_credentials:set(Creds, auth_module, ?MODULE)}. |
59 |
|
|
60 |
|
check_password(_HostType, _User, _Server, _Password) -> |
61 |
:-( |
true. |
62 |
|
|
63 |
|
check_password(_HostType, User, Server, _Password, _Digest, _DigestGen) -> |
64 |
:-( |
?LOG_DEBUG(#{what => digest_auth_unsupported, |
65 |
|
text => <<"no support for digest authentication">>, |
66 |
:-( |
user => User, server => Server}), |
67 |
:-( |
false. |
68 |
|
|
69 |
|
-spec set_password(mongooseim:host_type(), jid:luser(), jid:lserver(), binary()) -> ok. |
70 |
|
set_password(_HostType, _User, _Server, _Password) -> |
71 |
:-( |
ok. |
72 |
|
|
73 |
|
-spec try_register(mongooseim:host_type(), jid:luser(), jid:lserver(), binary()) -> ok. |
74 |
|
try_register(_HostType, _User, _Server, _Password) -> |
75 |
:-( |
ok. |
76 |
|
|
77 |
|
-spec get_password(mongooseim:host_type(), jid:luser(), jid:lserver()) -> binary(). |
78 |
|
get_password(_HostType, _User, _Server) -> |
79 |
:-( |
<<>>. |
80 |
|
|
81 |
|
-spec get_password_s(mongooseim:host_type(), jid:luser(), jid:lserver()) -> binary(). |
82 |
|
get_password_s(_HostType, _User, _Server) -> |
83 |
:-( |
<<>>. |
84 |
|
|
85 |
|
-spec does_user_exist(mongooseim:host_type(), jid:luser(), jid:lserver()) -> boolean(). |
86 |
|
does_user_exist(_HostType, _User, _Server) -> |
87 |
:-( |
true. |
88 |
|
|
89 |
|
%% @doc Remove user. |
90 |
|
%% Note: it returns ok even if there was some problem removing the user. |
91 |
|
-spec remove_user(mongooseim:host_type(), jid:luser(), jid:lserver()) -> ok. |
92 |
|
remove_user(_HostType, _User, _Server) -> |
93 |
:-( |
ok. |
94 |
|
|
95 |
|
-spec remove_domain(mongooseim:host_type(), jid:lserver()) -> ok. |
96 |
:-( |
remove_domain(_HostType, _Server) -> ok. |
97 |
|
|
98 |
|
-spec supported_features() -> [atom()]. |
99 |
61 |
supported_features() -> [dynamic_domains]. |
100 |
|
|
101 |
|
-spec supports_sasl_module(mongooseim:host_type(), cyrsasl:sasl_module()) -> boolean(). |
102 |
33 |
supports_sasl_module(_, cyrsasl_plain) -> true; |
103 |
242 |
supports_sasl_module(_, _) -> false. |
104 |
|
|
105 |
|
scram_passwords() -> |
106 |
:-( |
not_supported. |