summaryrefslogtreecommitdiff
path: root/src/storage.erl
diff options
context:
space:
mode:
authorMagnus Ahltorp <map@kth.se>2017-02-18 00:41:07 +0100
committerMagnus Ahltorp <map@kth.se>2017-02-18 00:41:07 +0100
commit8ecfbfa2a57708366763d7adbfcb87f9b0df7d03 (patch)
treec73012f287783d061a6bbf015dfe09b5dee1604d /src/storage.erl
parent8feab15047ea459eba1653b77157192f28ae5183 (diff)
Require that storage servers sign stored entriesstorage-signature
Diffstat (limited to 'src/storage.erl')
-rw-r--r--src/storage.erl11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/storage.erl b/src/storage.erl
index efe4768..489bf91 100644
--- a/src/storage.erl
+++ b/src/storage.erl
@@ -19,7 +19,10 @@ request(post, ?APPURL_PLOP_STORAGE, "sendentry", Input) ->
ok = db:add_entry_sync(TreeLeafHash, LogEntry),
ok = storagedb:add(TreeLeafHash),
- success({[{result, <<"ok">>}]})
+ {KeyName, Sig} = http_auth:sign_stored(plop:spt_from_entry(LogEntry)),
+ success({[{result, <<"ok">>},
+ {"sig", KeyName ++ ":" ++ base64:encode_to_string(Sig)}
+ ]})
end;
request(post, ?APPURL_PLOP_STORAGE, "entrycommitted", Input) ->
case (catch mochijson2:decode(Input)) of
@@ -30,6 +33,12 @@ request(post, ?APPURL_PLOP_STORAGE, "entrycommitted", Input) ->
LeafHash = base64:decode(proplists:get_value(<<"treeleafhash">>, PropList)),
db:add_entryhash(LeafHash, EntryHash),
db:commit_entryhash(),
+ case proplists:get_value(<<"timestamp_signature">>, PropList) of
+ undefined ->
+ none;
+ TimestampSignature ->
+ plop:add_spt(LeafHash, base64:decode(TimestampSignature))
+ end,
success({[{result, <<"ok">>}]})
end;
request(get, ?APPURL_PLOP_STORAGE, "fetchnewentries", _Input) ->