Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Currently, hosting the SyncStorage service under any root URL other than
/
like, say,/firefox-sync
, causes 401 HTTP error codes caused by mismatching Message Authentication Codes (or MACs for short) as pointed out by @ethowitz here.Changes made in this PR add a new option
public_url
allowing users to specify the public facing URL to the root of thesyncserver
s services.This
public_url
option is used for determining the original request uri and perform the MAC authentication properly.Things to Note
As explained by @kyz here, the host and port for performing the MAC authentication are taken from the
Forwarded
or theX-Forwarded-For
andX-Forwarded-Scheme
etc. headers:syncstorage-rs/syncserver/src/web/auth.rs
Lines 177 to 193 in 8c56cae
It might be a good idea to swap this to perform the authentication based on
public_url
if specified, instead. However, I did not include this in this PR and I would love to hear what other people think about this.Testing
syncserver
which is hosted under a root other than/
, for example:http://localhost:8080/firefox-sync
:http://localhost:8080/firefox-sync/1.0/sync/1.5
http://localhost:8080/firefox-sync/1.5/*
fail with a 401 HTTP codeIssue(s)
Closes #1217 and closes #1649.