Skip to content

docs: adds an expires field to the bearer token response #676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions http/peer-id-auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,17 @@ protocol operates as follows:
Authentication-Info: libp2p-PeerID sig="<base64-signature-bytes>" bearer="<base64-encoded-opaque-blob>"
```

The server MAY include an `expires` field which contains the expiry time of
the bearer token in [ISO-8601](https://www.iso.org/iso-8601-date-and-time-format.html)
Copy link
Contributor

@MarcoPolo MarcoPolo May 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should use RFC 3339 instead. It's a subset of ISO 8601 with a focus on simplicity and use over the internet.

In JS, I believe toISOString() is RFC 3339 compliant.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's what I meant. I'm all in favour of simplicity.

format:

```
Authentication-Info: libp2p-PeerID sig="<base64-signature-bytes>" bearer="<base64-encoded-opaque-blob>" expires="<ISO-8601-formatted-date-string>"
```

Note that the `expires` field is only advisory, the server may expire the
token at any time.

The `sig` param represents a signature over the parameters:

- `challenge-server`
Expand Down Expand Up @@ -254,6 +265,17 @@ The client initiated handshake is as follows
- The client's Peer ID.
- The `hostname` parameter.
- The token creation date (to allow tokens to expire).

The server MAY include an `expires` field which contains the expiry time of
the bearer token in [ISO-8601](https://www.iso.org/iso-8601-date-and-time-format.html)
format:

```
Authentication-Info: libp2p-PeerID bearer="<base64-encoded-opaque-blob>" expires="<ISO-8601-formatted-date-string>"
```

Note that the `expires` field is only advisory, the server may expire the
token at any time.

5. The client SHOULD send the `bearer` token for future Peer ID authenticated
requests.
Expand Down