summaryrefslogtreecommitdiff
path: root/src/http_auth.erl
diff options
context:
space:
mode:
authorMagnus Ahltorp <map@kth.se>2017-01-20 00:30:36 +0100
committerMagnus Ahltorp <map@kth.se>2017-01-20 00:30:36 +0100
commit784f116ba3fad8e28ef2fefd86d5df71801dbe6f (patch)
tree409e53de64335664b2944baa1e1880b9f5565ece /src/http_auth.erl
parent109fc863b5ebec2d502c55df1f763c8f0ecb4722 (diff)
API keys are now provided in config file
Also added CA cert verification for internal TLS connections.
Diffstat (limited to 'src/http_auth.erl')
-rw-r--r--src/http_auth.erl20
1 files changed, 3 insertions, 17 deletions
diff --git a/src/http_auth.erl b/src/http_auth.erl
index a187e05..16d7dfa 100644
--- a/src/http_auth.erl
+++ b/src/http_auth.erl
@@ -17,24 +17,10 @@ init_key_table() ->
read_key_table().
read_key_table() ->
- PublickeyDir = application:get_env(plop, publickey_path, none),
- ServersACL = application:get_env(plop, allowed_servers, []),
- ClientsACL = application:get_env(plop, allowed_clients, []),
- Keys = sets:from_list(
- lists:flatmap(fun ({_, Keys}) ->
- case Keys of
- noauth ->
- [];
- _ when is_list(Keys) ->
- Keys
- end
- end, ServersACL ++ ClientsACL)),
lists:foreach(
- fun (KeyName) ->
- Key = sign:read_keyfile_ec(PublickeyDir ++ "/" ++
- KeyName ++ ".pem"),
- true = ets:insert(?KEY_TABLE, {KeyName, Key})
- end, sets:to_list(Keys)),
+ fun ({KeyName, Der}) ->
+ true = ets:insert(?KEY_TABLE, {KeyName, sign:pem_entry_decode({'SubjectPublicKeyInfo', Der, []})})
+ end, application:get_env(plop, apikeys, [])),
case application:get_env(plop, own_key, none) of
{_OwnKeyName, OwnKeyFile} ->
OwnKey = sign:read_keyfile_ec(OwnKeyFile),