Skip to content
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

feat(libp2phttp): More ergonomic auth #3188

Merged
merged 2 commits into from
Feb 25, 2025

Conversation

MarcoPolo
Copy link
Collaborator

@MarcoPolo MarcoPolo commented Feb 13, 2025

Auth is now uniform across HTTP and stream transports and easier to use. See ExampleHost_authenticatedHTTP for an example. This will also show up in the docs page.

Adds:

  • ServerPeerID() function to get a server's peer id from an *http.Response. Used by clients.
  • ClientPeerID() function to get a client's peer id from an *http.Request. Used by servers.
  • ServerPeerIDAuth and ClientPeerIDAuth fields in the http.Host struct, to specify the key used to authenticate.

@MarcoPolo MarcoPolo requested a review from sukunrt February 13, 2025 19:47
Comment on lines 582 to 583
// Include after path since it may include other relevant parts (/p2p?)
if afterPath != nil {
withNewPath = withNewPath.Encapsulate(afterPath)
}
Copy link
Member

@sukunrt sukunrt Feb 24, 2025

Choose a reason for hiding this comment

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

NIT:

I think the /p2p bit in the comment is wrong, as the spec says p2p must come before:

https://github.com/multiformats/multiaddr/blob/master/protocols/http-path.md?plain=1#L27

But the logic seems okay.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks. Looking at this method, it isn't handling relative uris properly. I'll
fix it now.

@sukunrt
Copy link
Member

sukunrt commented Feb 24, 2025

Can you add some detail to the PR description for the change. Would be nice to be able to git blame and see what's happening.

Auth is now more uniform across HTTP and stream transports.
@MarcoPolo MarcoPolo force-pushed the marco/libp2phttpauth-ergonomics branch from 1828d07 to 451a39b Compare February 25, 2025 00:00
@MarcoPolo MarcoPolo merged commit 3e51326 into master Feb 25, 2025
11 checks passed
@MarcoPolo MarcoPolo mentioned this pull request Feb 25, 2025
19 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants