summaryrefslogtreecommitdiff
path: root/src/ldapsp_config.erl
blob: 73d15bdf45ef54b17752e130eb6f53cfc4fa0822 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
-module(ldapsp_config).

-export([
	 dispatch/0,
	 web_config/0,
	 ldap_config/0,
	 policy_config/0
]).


-spec dispatch() -> [webmachine_dispatcher:route()].
dispatch() ->
    Resources = [ldapsp_features,
		 ldapsp_realm,
		 ldapsp_realm_hostname
		],
    lists:flatten([Module:routes() || Module <- Resources]).

web_config() ->
    {ok, App} = application:get_application(?MODULE),
    {ok, Ip} = application:get_env(App, web_ip),
    {ok, Port} = application:get_env(App, web_port),
    [
     {ip, Ip},
     {port, Port},
     {log_dir, "priv/log"},
     {dispatch, dispatch()}
    ].

ldap_config() ->
    {ok, Config } = file:consult("priv/ldapsp.conf"),
    Con = proplists:get_value(connection, Config),
    [{server, proplists:get_value(server, Con)},
     {user, proplists:get_value(user, Con)},
     {password, proplists:get_value(password, Con)}].

policy_config() ->
    {ok, _Module} = compile:file("priv/policy.erl").