Skip to content

feat(libp2phttp): More ergonomic auth#3188

Merged
MarcoPolo merged 2 commits into
masterfrom
marco/libp2phttpauth-ergonomics
Feb 25, 2025
Merged

feat(libp2phttp): More ergonomic auth#3188
MarcoPolo merged 2 commits into
masterfrom
marco/libp2phttpauth-ergonomics

Conversation

@MarcoPolo
Copy link
Copy Markdown
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 thread p2p/http/libp2phttp.go Outdated
Comment thread p2p/http/libp2phttp.go Outdated
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
@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