1 |
|
-module(mongoose_ldap_config). |
2 |
|
|
3 |
|
%% Config spec |
4 |
|
-export([uids/0, |
5 |
|
dn_filter/0, |
6 |
|
local_filter/0]). |
7 |
|
|
8 |
|
%% Config spec callbacks |
9 |
|
-export([process_uids/1, |
10 |
|
process_dn_filter/1, |
11 |
|
process_local_filter/1]). |
12 |
|
|
13 |
|
-include("mongoose_config_spec.hrl"). |
14 |
|
|
15 |
|
uids() -> |
16 |
320 |
#section{ |
17 |
|
items = #{<<"attr">> => #option{type = binary}, |
18 |
|
<<"format">> => #option{type = binary}}, |
19 |
|
process = fun ?MODULE:process_uids/1, |
20 |
|
required = [<<"attr">>], |
21 |
|
format_items = map |
22 |
|
}. |
23 |
|
|
24 |
|
dn_filter() -> |
25 |
160 |
#section{ |
26 |
|
items = #{<<"filter">> => #option{type = binary, |
27 |
|
validate = ldap_filter}, |
28 |
|
<<"attributes">> => #list{items = #option{type = binary}} |
29 |
|
}, |
30 |
|
required = [<<"filter">>], |
31 |
|
defaults = #{<<"attributes">> => []}, |
32 |
|
process = fun ?MODULE:process_dn_filter/1, |
33 |
|
format_items = map |
34 |
|
}. |
35 |
|
|
36 |
|
local_filter() -> |
37 |
160 |
#section{ |
38 |
|
items = #{<<"operation">> => #option{type = atom, |
39 |
|
validate = {enum, [equal, notequal]}}, |
40 |
|
<<"attribute">> => #option{type = string, |
41 |
|
validate = non_empty}, |
42 |
|
<<"values">> => #list{items = #option{type = string}, |
43 |
|
validate = non_empty} |
44 |
|
}, |
45 |
|
required = all, |
46 |
|
process = fun ?MODULE:process_local_filter/1, |
47 |
|
format_items = map |
48 |
|
}. |
49 |
|
|
50 |
:-( |
process_uids(#{attr := Attr, format := Format}) -> {Attr, Format}; |
51 |
:-( |
process_uids(#{attr := Attr}) -> Attr. |
52 |
|
|
53 |
|
process_dn_filter(#{filter := Filter, attributes := Attrs}) -> |
54 |
:-( |
{Filter, Attrs}. |
55 |
|
|
56 |
|
process_local_filter(#{operation := Op, attribute := Attr, values := Values}) -> |
57 |
:-( |
{Op, {Attr, Values}}. |