-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
event: ["say_hello"] | ||
priority: 1 | ||
|
||
local port = ctx.msg.path_segments[2] | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
local date = tostring(time.now()) | ||
local body = '{"title":"Hello Message","type":"msg","text":"Hello"}' | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
--local signature_string = "date: " .. date .. "\n" .. body | ||
signature_string = "a" | ||
This comment has been minimized.
Sorry, something went wrong. |
||
log.trace("signature string", signature_string) | ||
|
||
-- from torchbear/src/lua_bindings/crypto/mod.rs at line 129 | ||
local key = crypto.sign.load_secret("+qEY1pRSYy7gTfJ58GLrDQTuhgiTf49Cy9yEgvix3vHGkq2b5t55E36RPtVYgnTn+2SF0Of8nEeVOyTvcvlnnQ==") | ||
|
||
local signature = key:sign_detached(signature_string) | ||
|
||
local signature_header = 'keyId="alice",algorithm="rsa-sha256",signature="' .. signature .. '"' | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Arnaz87
Author
Collaborator
|
||
|
||
local response = ClientRequest.build() | ||
:method("POST") | ||
:uri("http://localhost:" .. port .. "/") | ||
:headers({ | ||
["content-type"] = "application/json", | ||
["date"] = date, | ||
["signature"] = signature_header, | ||
}) | ||
This comment has been minimized.
Sorry, something went wrong.
naturallymitchell
Member
|
||
:send_with_body(body) | ||
|
||
--local inspect = require "inspect" | ||
|
||
return { | ||
headers = { | ||
["content-type"] = "application/json", | ||
}, | ||
body = '{"message":"said hello"}' | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
event: ["reqProcess"] | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
priority: 1 | ||
|
||
-- TODO: the headers part of the signature header is being ignored. | ||
-- every header listed in headers, separated with spaces, must be included | ||
|
||
local header = req.headers["signature"] | ||
log.trace("signature header", header) | ||
|
||
if not header then log.info("Unsigned Request") return end | ||
|
||
local keys = { | ||
alice = "xpKtm+beeRN+kT7VWIJ05/tkhdDn/JxHlTsk73L5Z50=" | ||
} | ||
|
||
local keyId, signature = header:match('keyId="(%a+)".+signature="([^"]+)"') | ||
log.debug("keyId", keyId) | ||
log.debug("signature", signature) | ||
|
||
--[=[ | ||
local sig_parts = {} | ||
for _, part in ipairs(header:split(",")) do | ||
local ps = part:split("=") | ||
-- remove start and end quotes (doesn't handle escape sequences) | ||
sig_parts[ps[1]] = ps[2]:sub(2, -2) | ||
end | ||
log.trace("signature parts") | ||
for k, v in pairs(sig_parts) do | ||
log.debug(k, v) | ||
end | ||
local signature = sig_parts.signature | ||
]=] | ||
|
||
local key = crypto.sign.load_public(keys[keyId]) | ||
log.trace("public key for", keyId, key) | ||
|
||
local signature_string = "date: " .. req.headers.date .. "\n" .. req.body_raw | ||
signature_string = "a" | ||
log.trace("signature string", signature_string) | ||
|
||
local is_valid = key:verify_detached(signature_string, signature) | ||
if is_valid then | ||
log.info("request signature is valid") | ||
else | ||
log.warn("invalid request signature") | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Arnaz87
Author
Collaborator
|
||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
key_generation_request | ||
witness_request | ||
send_key | ||
say_hello |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
if req.method == "GET" | ||
and #req.path_segments == 2 | ||
and req.path_segments[1] == "say_hello" | ||
then | ||
events["say_hello"]:trigger() | ||
end |
5 comments
on commit ebd5dd8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
verify_signature.action
(executes before lighttouch-api/create_document_local.action)
- first action strip trusted header
- put trusted header on if it checks out with any key
lighttouch-api/create_document_local.action
puts content in content/profile-key-id/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
verify_signature should move to lighttouch-api
creating new keys should stay here and have a web interface
sending keys to friends should stay here as an action, hopefully at some point there will be a repl or better yet a lighttouch-admin for doing this stuff, the url scheme pays of anyway
/admin/keys/ ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
verify_signature needs to know where to get the public key according to keyId, how would we do that lighttouch-keys?
there should be a sign_request action somewhere as well, where should that go?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this shows where the content moves
jazzdotdev-packages/json-interface#4
and in content/[key-uuid]/ <- content from us, eg keys
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
profile has a name field
key has a type: box/seal , kind: pub/priv , and uuid of profile
content/home/[uuid of review] - says that profile is good
ctx.msg
is bound torequest
, isn't it?