Alternative to #177
The way this works is:
Client:
- Client creates a normal `net/http.Request{}` object using the `Request()` function in `utils.go`. The `http.Request{}` object is then signed using the Client's Ed25519 private key.
- The HTTP Method and Path (_note this is important_) are hashed, as well as the request body (if any) using the FNV128a hashing algorithm.
- This hash is then signed by the Client's's Ed25519 private key.
- The resulting signature is then encoded to Base64 (_standard encoding_) and added to the HTTP headers as a `Signature:` header.
- In addition the Client's Ed25519 public key is added to the HTTP headers as `Signer:`
Server:
- The server calculates the same FNV128a hash of the HTTP Request Method and Path and the body (if any)
- The server decodes the HTTP header `Signature:`
- The server then uses the Client's Ed25519 public key in the HTTP header `Signer:` to verify the signature of the `Signature:` HTTP header which gives us back the original FNV128a hash the Client calculated for the request.
- The server then compares the Client's hash with the expected hash to see if they compare equally.
Co-authored-by: James Mills <1290234+prologic@users.noreply.github.com>
Co-authored-by: Jon Lundy <jon@xuu.cc>
Reviewed-on: https://git.mills.io/saltyim/saltyim/pulls/178
Reviewed-by: xuu <xuu@noreply@mills.io>
Fixes#169
This now behaves like this:
```
/Users/prologic/Projects/saltyim/saltyim # ./salty-chat write prologic@mills.io test
WARN[0000] error looking up user endpoint error="error looking up user testing123@shortcircuit.net.au: non-2xx response received: 404 Not Found"
error initializing client: unable to find your endpoint for testing123@shortcircuit.net.au
/Users/prologic/Projects/saltyim/saltyim #
```
Co-authored-by: James Mills <prologic@shortcircuit.net.au>
Reviewed-on: https://git.mills.io/saltyim/saltyim/pulls/171
Reviewed-by: m u t e f a l l <mutefall@noreply@mills.io>
See #169 which this patch partially fixes one issue found but not the most critical one (hence this PR does not close the issue)
Co-authored-by: James Mills <prologic@shortcircuit.net.au>
Reviewed-on: https://git.mills.io/saltyim/saltyim/pulls/170
Reviewed-by: m u t e f a l l <mutefall@noreply@mills.io>
Improves how inbox indices are peristed, hopefully much better now as the topic sequences are now a proper monotonic increasing integer, messages survive crashes/resrarts and so forth.
- [] Remove the `go.mod` replace directive after https://git.mills.io/prologic/msgbus/pulls/33 is merged
cc @xuu
Co-authored-by: James Mills <prologic@shortcircuit.net.au>
Reviewed-on: https://git.mills.io/saltyim/saltyim/pulls/136
Reviewed-by: xuu <xuu@noreply@mills.io>
This PR also:
- Tidies up the default options and config
- Tidies up the service user code
Co-authored-by: James Mills <prologic@shortcircuit.net.au>
Reviewed-on: https://git.mills.io/saltyim/saltyim/pulls/116
feat: add compression negotiation for sent messages
fix: unix homedir handling
the service will negotiate a compression algo for sending messages
when a user chats someone during the auto discovery, the service returns an `Accept-Encoding: br, gzip, deflate`
the client saves that response and so when it makes POSTs of messages adds the best `Content-Encoding` and compresses the message
example:
```
>> GET /.well-known/salty/c765c69040d98f3af2181237f47ec01398d80f8ab2690fe929e4311ab05dec01.json
<< Accept-Encoding: br, gzip, deflate
<<
<< {"endpoint":"https://salty.home.arpa/inbox/01FZBR8Y2E6TH949JA3925WF71","key":"kex1wurry09ftqjuxgjl0jxmqypv4axqvzqljkgeadxjcpwtfuhcedcslck52d"}
>> POST /inbox/01FZBR8Y2E6TH949JA3925WF71
>> Content-Encoding: br
>>
>> [Brotli Compressed data]
```
this PR depends on https://git.mills.io/prologic/msgbus/pulls/24
Co-authored-by: Jon Lundy <jon@xuu.cc>
Reviewed-on: https://git.mills.io/saltyim/saltyim/pulls/91
Co-authored-by: xuu <xuu@noreply@mills.io>
Co-committed-by: xuu <xuu@noreply@mills.io>
This PR is for refactoring interaction with CreateIdentity(), GetIdentity(), and NewClient() to allow operations on the identity contents from within a PWA where a filesystem is not present.
It was suggested to use functional arguments so this pull request reflects this.
Co-authored-by: mlctrez <mlctrez@gmail.com>
Reviewed-on: https://git.mills.io/saltyim/saltyim/pulls/53
Co-authored-by: mlctrez <mlctrez@noreply@mills.io>
Co-committed-by: mlctrez <mlctrez@noreply@mills.io>
As per title.
Was quite a bit confusing there, but worked it out in the end!
Co-authored-by: Phil S <ullarah@noreply@mills.io>
Reviewed-on: https://git.mills.io/prologic/saltyim/pulls/45
Co-authored-by: Phil S. <ullarah@noreply@mills.io>
Co-committed-by: Phil S. <ullarah@noreply@mills.io>