./ct_report/coverage/ejabberd_auth_dummy.COVER.html

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 45 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 104 #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 format_items = map
52 }.
53
54 authorize(Creds) ->
55 8 HostType = mongoose_credentials:host_type(Creds),
56 8 #{base_time := Base,
57 variance := Variance} = mongoose_config:get_opt([{auth, HostType}, dummy]),
58 8 timer:sleep(Base + rand:uniform(Variance)),
59 8 {ok, mongoose_credentials:set(Creds, auth_module, ?MODULE)}.
60
61 check_password(_HostType, _User, _Server, _Password) ->
62
:-(
true.
63
64 check_password(_HostType, User, Server, _Password, _Digest, _DigestGen) ->
65
:-(
?LOG_DEBUG(#{what => digest_auth_unsupported,
66 text => <<"no support for digest authentication">>,
67
:-(
user => User, server => Server}),
68
:-(
false.
69
70 -spec set_password(mongooseim:host_type(), jid:luser(), jid:lserver(), binary()) -> ok.
71 set_password(_HostType, _User, _Server, _Password) ->
72
:-(
ok.
73
74 -spec try_register(mongooseim:host_type(), jid:luser(), jid:lserver(), binary()) -> ok.
75 try_register(_HostType, _User, _Server, _Password) ->
76
:-(
ok.
77
78 -spec get_password(mongooseim:host_type(), jid:luser(), jid:lserver()) -> binary().
79 get_password(_HostType, _User, _Server) ->
80
:-(
<<>>.
81
82 -spec get_password_s(mongooseim:host_type(), jid:luser(), jid:lserver()) -> binary().
83 get_password_s(_HostType, _User, _Server) ->
84
:-(
<<>>.
85
86 -spec does_user_exist(mongooseim:host_type(), jid:luser(), jid:lserver()) -> boolean().
87 does_user_exist(_HostType, _User, _Server) ->
88
:-(
true.
89
90 %% @doc Remove user.
91 %% Note: it returns ok even if there was some problem removing the user.
92 -spec remove_user(mongooseim:host_type(), jid:luser(), jid:lserver()) -> ok.
93 remove_user(_HostType, _User, _Server) ->
94
:-(
ok.
95
96 -spec remove_domain(mongooseim:host_type(), jid:lserver()) -> ok.
97
:-(
remove_domain(_HostType, _Server) -> ok.
98
99 -spec supported_features() -> [atom()].
100 45 supported_features() -> [dynamic_domains].
101
102 -spec supports_sasl_module(mongooseim:host_type(), cyrsasl:sasl_module()) -> boolean().
103 24 supports_sasl_module(_, cyrsasl_plain) -> true;
104 176 supports_sasl_module(_, _) -> false.
105
106 scram_passwords() ->
107
:-(
not_supported.
Line Hits Source