From d5ec85ae2d9d796b220509541c9e79ca07518faf Mon Sep 17 00:00:00 2001 From: Marco Munizaga Date: Mon, 26 Aug 2024 17:43:29 -0700 Subject: [PATCH] Wordsmithing --- http/peer-id-auth.md | 55 +++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/http/peer-id-auth.md b/http/peer-id-auth.md index d8542e8..88c3e92 100644 --- a/http/peer-id-auth.md +++ b/http/peer-id-auth.md @@ -18,15 +18,15 @@ scheme is called `libp2p-PeerID`. ## Parameters -| Param Name | Description | -| ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| hostname | The server name used in the TLS connection (SNI). | -| challenge-server | The random quoted string value the client generates to challenge the server to prove its identity | -| challenge-client | The random quoted string value the server generates to challenge the client to prove its identity | -| sig | A base64 encoded signature. | -| peer-id | The Peer ID of the node that set this parameter. Encoding defined by the [Peer ID spec]. | -| public-key | A base64 encoded value of peer's public key. The key itself is encoded per the [Peer ID spec]. | -| opaque | An base64 encoded value opaque to the client blob generated by the server. If a client receives this it must return it. A server may use this to authenticate statelessly. For example, it could store the challenge-client and a expiry time. | +| Param Name | Description | +| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| hostname | The server name used in the TLS connection (SNI). | +| challenge-server | The random quoted string value the client generates to challenge the server to prove its identity | +| challenge-client | The random quoted string value the server generates to challenge the client to prove its identity | +| sig | A base64 encoded signature. | +| peer-id | The Peer ID of the node that set this parameter. Encoding defined by the [Peer ID spec]. | +| public-key | A base64 encoded value of peer's public key. The key itself is encoded per the [Peer ID spec]. | +| opaque | A value opaque to the client blob generated by the server. If a client receives this it must return it. A server may use this to authenticate statelessly. For example, it could store the challenge-client and a expiry time. | Params are encoded per [RFC 9110 auth-param's ABNF](https://datatracker.ietf.org/doc/html/rfc9110#name-cmaollected-abnf). Generally it'll be something like: `hostname="example.com", challenge-server="challenge-string"` @@ -74,10 +74,10 @@ protocol operates as follows: encode state. 3. The client makes another HTTP request to the same authenticated resource and sets the header: ``` - Authorization: libp2p-PeerID peer-id="", opaque="", challenge-server=""[,encoded-public-key="" ], sig="" + Authorization: libp2p-PeerID peer-id="", opaque="", challenge-server="",[ public-key="",] sig="" ``` - The `encoded-public-key` param is optional and represents the client's public key. This is only needed when the client's public key is not included in the PeerID (e.g. not using the "identity" multihash). + The `public-key` param is optional and represents the client's public key. This is only needed when the client's public key is not included in the PeerID (e.g. not using the "identity" multihash). The `sig` param represents a signature over the parameters: - `hostname` @@ -87,34 +87,41 @@ protocol operates as follows: validate the signature. If the signature is valid, the server has authenticated the client's Peer ID. The server SHOULD proceed to serve the HTTP request. The server MUST set the following response headers: ``` - Authentication-Info: libp2p-PeerID peer-id="", sig="", libp2p-Bearer + Authentication-Info: libp2p-PeerID peer-id="", sig=""[, public-key=""] bearer="" ``` + + Again, the `public-key` param is optional and represents the server's public key. This is only needed when the public key is not included in the PeerID (e.g. not using the "identity" multihash). + The `sig` param represents a signature over the parameters: - `hostname` - `challenge-server` - - `client-pubkey` the bytes of the client's public key + - `client-peer-id` the string representation fo the client's peer id - The `libp2p-Bearer` token allows the client to make future Peer ID authenticated + The `bearer` token allows the client to make future Peer ID authenticated requests. The value is opaque to the client, and the server may use it to store authentication state such as: - The client's Peer ID. - The `hostname` parameter. - The token creation date (to allow tokens to expire). 5. The client MUST verify the signature. After verification the client has - authenticated the server's Peer ID. The client MUST send the `libp2p-Bearer` + authenticated the server's Peer ID. The client SHOULD send the `bearer` token for Peer ID authenticated requests. -## libp2p Bearer token +## libp2p bearer token -The libp2p Bearer token is a token given to the client from the server that +The libp2p bearer token is a token given to the client from the server that allows the client (the bearer) to make Peer ID authenticated requests to the -server. Once the client receives this token after the Mutual Authentication -protocol, the client should save it and use it for future authenticated -requests. +server. Once the client receives this token, they SHOULD save it and use it +for future authenticated requests. The server SHOULD return a 401 Unauthorized and follow the above Mutual -authentication protocol when it wants the client to request a new libp2p Bearer -token. +authentication protocol when it wants the client to request a new libp2p +bearer token. + +To use the bearer token, the client MUST set the Authorization header as follows: +``` +Authorization: libp2p-PeerID bearer="" +``` ## Authentication URI Endpoint @@ -167,7 +174,7 @@ Included is a concrete example of running the protocol. The client uses the Peer ``` 4. The server responds with the header: ``` - Authentication-Info: libp2p-PeerID peer-id="12D3KooWDpJ7As7BWAwRMfu1VU2WCqNjvq387JEYKDBj4kx6nXTN", sig="btLFqW200aDTQqpkKetJJje7V-iDknXygFqPsfiegNsboXeYDiQ6Rqcpezz1wfr8j9h83QkN9z78cAWzKzV_AQ==", libp2p-Bearer + Authentication-Info: libp2p-PeerID peer-id="12D3KooWDpJ7As7BWAwRMfu1VU2WCqNjvq387JEYKDBj4kx6nXTN", sig="btLFqW200aDTQqpkKetJJje7V-iDknXygFqPsfiegNsboXeYDiQ6Rqcpezz1wfr8j9h83QkN9z78cAWzKzV_AQ==", bearer="" ``` @@ -186,7 +193,7 @@ The following table lists out all parameters and intermediate values used in the | The client's Authorization header | `Authorization: libp2p-PeerID peer-id="12D3KooWBtg3aaRMjxwedh83aGiUkwSxDwUZkzuJcfaqUmo7R3pq", opaque="CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC=", challenge-server="BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB=", sig="F5OBYbbMXoIVJNWrW0UANi7rrbj4GCB6kcEceQjajLTMvC-_jpBF9MFlxiaNYXOEiPQqeo_S56YUSNinwl0ZCQ=="` | | What the server will sign (percent encoded) | `todo` | | The server's signature | `todo` | -| The server's Authentication-Info header | `Authentication-Info: libp2p-PeerID peer-id="12D3KooWDpJ7As7BWAwRMfu1VU2WCqNjvq387JEYKDBj4kx6nXTN", sig="btLFqW200aDTQqpkKetJJje7V-iDknXygFqPsfiegNsboXeYDiQ6Rqcpezz1wfr8j9h83QkN9z78cAWzKzV_AQ==", libp2p-Bearer ` | +| The server's Authentication-Info header | `Authentication-Info: libp2p-PeerID peer-id="12D3KooWDpJ7As7BWAwRMfu1VU2WCqNjvq387JEYKDBj4kx6nXTN", sig="btLFqW200aDTQqpkKetJJje7V-iDknXygFqPsfiegNsboXeYDiQ6Rqcpezz1wfr8j9h83QkN9z78cAWzKzV_AQ==", bearer=""` | [Peer ID spec]: https://github.com/libp2p/specs/blob/master/peer-ids/peer-ids.md