Browse Source

namespaced modules

Daniel Moore 11 years ago
parent
commit
eb091cf4d0
3 changed files with 8 additions and 12 deletions
  1. 5 9
      src/ldap_auth_config.erl
  2. 2 2
      src/ldap_auth_gateway.erl
  3. 1 1
      src/main.erl

+ 5 - 9
src/config.erl → src/ldap_auth_config.erl

@@ -6,20 +6,16 @@
 %%% @end
 %%% Created : 08. Oct 2013 10:25 PM
 %%%-------------------------------------------------------------------
--module(config).
+-module(ldap_auth_config).
 -author("dmoore").
 
 %% API
 -export([get_config/1]).
+-include_lib("couch/include/couch_db.hrl").
 
 get_config([]) -> [];
 get_config([Key|Rem]) ->
-  [case Key of
-    "UseSsl" -> false;
-    "LdapServer" -> "atlas.northhorizon.local";
-     "BaseDN" -> "DC=northhorizon,DC=local";
-     "SearchUserDN" -> "CN=ldapsearch,CN=Users,DC=northhorizon,DC=local";
-     "SearchUserPassword" -> "Welcome1";
-     "UserDNMapAttr" -> "userPrincipalName";
-     "GroupDNMapAttr" -> "name"
+  [case couch_config:get("ldap_auth", Key, undefined) of
+    undefined -> throw({config_key_not_found, "Key not found in [ldap_auth] section of config: " ++ Key});
+    Value -> Value
   end | get_config(Rem)].

+ 2 - 2
src/ldap_integration.erl → src/ldap_auth_gateway.erl

@@ -6,7 +6,7 @@
 %%% @end
 %%% Created : 08. Oct 2013 10:21 PM
 %%%-------------------------------------------------------------------
--module(ldap_integration).
+-module(ldap_auth_gateway).
 -author("dmoore").
 
 -include_lib("eldap/include/eldap.hrl").
@@ -14,7 +14,7 @@
 %% API
 -export([connect/0, authenticate/3, get_group_memberships/2]).
 
--import(config, [get_config/1]).
+-import(ldap_auth_config, [get_config/1]).
 
 authenticate(LdapConnection, User, Password) ->
   [UserDNMapAttr] = get_config(["UserDNMapAttr"]),

+ 1 - 1
src/main.erl

@@ -22,7 +22,7 @@
 
 -include_lib("eldap/include/eldap.hrl").
 
--import(ldap_integration, [connect/0, authenticate/3, get_group_memberships/2]).
+-import(ldap_auth_gateway, [connect/0, authenticate/3, get_group_memberships/2]).
 
 start() ->
 %%   User = string:strip(io:get_line("User: "), right, $\n),