summaryrefslogtreecommitdiff
path: root/src/storage.erl
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordu.net>2017-03-01 09:54:07 +0100
committerLinus Nordberg <linus@nordu.net>2017-03-01 09:54:07 +0100
commita6652b80f4281cfc7cbf78c008342e2fda36c715 (patch)
treecaab69e703adaee7b0669e38ccc99f305991ef0d /src/storage.erl
parent21a7ceeda03f851da2643e175c2dff7b0a012fe1 (diff)
parent11fc428f6eb52936bdbde1be5a6cd4e56704bc68 (diff)
Merge branch 'map-storage-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..c64d918 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_data_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) ->