add http authentication protocol

This commit is contained in:
2025-02-02 11:12:50 -01:06
parent 7eba0a1ddb
commit 786cc0108c
2 changed files with 16 additions and 2 deletions

View File

@@ -30,13 +30,27 @@ It is unnecessary messages and work to use websockets for queries that match the
There can be a separate subscription type also, where there is delivering the IDs only, or forwarding the whole event. There can be a separate subscription type also, where there is delivering the IDs only, or forwarding the whole event.
=== HTTP Authentication
For the most part, all queries and submissions must be authenticated in order to enable a REALY relay to allow access.
To enable this, a suffix is added to messages with the following format:
`<message payload>\n` // all messages must be terminated with a newline
`<unix timestamp in decimal ascii>:<public key of signer>:<signature>\n`
For reasons of security, a relay should not allow a time skew in the timestamp of more than 15 seconds.
The signature is upon the Blake 2b message hash of everything up to the semicolon preceding it.
== Events == Events
The format of events is as follows - the monospace segments are the exact text, including the necessary linebreak characters, the rest is descriptive. The format of events is as follows - the monospace segments are the exact text, including the necessary linebreak characters, the rest is descriptive.
--- ---
`<type name>\n` // can be anything, hierarchic names like note/html note/md are possible `<type name>\n` // can be anything, hierarchic names like note/html note/md are possible, or type.subtype or whatever
`<pubkey>\n` // encoded in URL-base64 with the padding `=` elided `<pubkey>\n` // encoded in URL-base64 with the padding `=` elided

View File

@@ -7,7 +7,7 @@ import (
"testing" "testing"
) )
func TestP_Marshal_Unmarshal(t *testing.T) { func TestT_Marshal_Unmarshal(t *testing.T) {
var err error var err error
for range 10 { for range 10 {
pk := make([]byte, ed25519.PublicKeySize) pk := make([]byte, ed25519.PublicKeySize)