Skip to content

Comments

RFC 9540 directory and receiver#549

Merged
DanGould merged 4 commits intopayjoin:masterfrom
nothingmuch:rfc-9540-directory-and-receiver
Mar 11, 2025
Merged

RFC 9540 directory and receiver#549
DanGould merged 4 commits intopayjoin:masterfrom
nothingmuch:rfc-9540-directory-and-receiver

Conversation

@nothingmuch
Copy link
Collaborator

This is a backwards compatible change to support RFC 9540.

The directory accepts requests at /.well-known/ohttp-gateway. The receiver also fetches OHTTP keys from the new RFC 9540 endpoint, instead of /ohttp-keys.

Unblocks payjoin/ohttp-relay#47.

@coveralls
Copy link
Collaborator

coveralls commented Feb 21, 2025

Pull Request Test Coverage Report for Build 13777715320

Details

  • 10 of 12 (83.33%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.03%) to 79.738%

Changes Missing Coverage Covered Lines Changed/Added Lines %
payjoin/src/io.rs 2 4 50.0%
Totals Coverage Status
Change from base Build 13751979319: 0.03%
Covered Lines: 4569
Relevant Lines: 5730

💛 - Coveralls

@nothingmuch nothingmuch force-pushed the rfc-9540-directory-and-receiver branch from 009604c to eca7fe4 Compare February 21, 2025 22:50
@nothingmuch nothingmuch marked this pull request as draft February 21, 2025 23:14
@DanGould
Copy link
Contributor

gotta add the ACCEPT header first

@nothingmuch nothingmuch force-pushed the rfc-9540-directory-and-receiver branch from eca7fe4 to 3a09e8e Compare February 21, 2025 23:25
@nothingmuch nothingmuch marked this pull request as ready for review February 21, 2025 23:26
Comment on lines +81 to +84
pub fn ohttp_gateway_url(&self) -> Url {
let url = self.directory_url();
url.join("/.well-known/ohttp-gateway").expect("invalid URL")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it may make more sense to have our extract_req fns themselves url.join("/.well-known/ohttp-gateway").expect("invalid URL") since the path is the same for all functions assuming RFC 9540 compliance. That way the end user only needs to pass the directory origin and not the complete gateway url.

I suppose this would make it impossible to use our crate with non-RFC 9540-compliant directories, but I think that's our intended behavior.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is not actually relevant, as it is the relay which appends that path

Only the key bootstrapping GET request explicitly specifies the RFC 9540 path, which for now is optional since the old /ohttp-keys route is still supported, that functionality accepts the payjoin directory base URI as before.

The reason this method is provided is for the integration tests which bypass the relay.

@nothingmuch nothingmuch changed the title Rfc 9540 directory and receiver RFC 9540 directory and receiver Feb 22, 2025
The gateway is available via POST on /.well-known/ohttp-gateway

OHTTP key configuration is available via GET on the same path. In this
case the `Accept: application/ohttp-keys` is not required or even
checked.
This change utilizes the new RFC 9540 behavior in the directory for
fetching ohttp keys, and exercises this as well as OHTTP gateway
functionality in the tests which bypass the ohttp-relay.
Copy link
Contributor

@DanGould DanGould left a comment

Choose a reason for hiding this comment

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

ACK 09ffcfa

let proxy = Proxy::all(ohttp_relay.into_url()?.as_str())?;
let client = Client::builder().proxy(proxy).build()?;
let res = client.get(ohttp_keys_url).send().await?;
let res = client.get(ohttp_keys_url).header(ACCEPT, "application/ohttp-keys").send().await?;
Copy link
Contributor

@DanGould DanGould Mar 11, 2025

Choose a reason for hiding this comment

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

You mention in the commit messages that this isn't checked anywhere in the directory. Is there a plan to require that? Seems to not make a huge difference.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

no, it seems needlessly pedantic to me, but i thought it was worth mentioning in case anyone disagrees

@DanGould DanGould merged commit 9be4bd3 into payjoin:master Mar 11, 2025
7 checks passed
@nothingmuch
Copy link
Collaborator Author

Hmm, I mischaracterized this PR. The directory side is backwards compatible, since it will handle older requests too.

However, the bootstrapping code for the client depends on the new functionality, from the relay. I think I originally intended to split this PR into two parts, so we could release the directory first and and only then merge a separate PR to the receiver, but I'm not 100% sure and either way I neglected to do that, sorry.

@nothingmuch nothingmuch deleted the rfc-9540-directory-and-receiver branch March 12, 2025 14:32
nothingmuch added a commit that referenced this pull request Mar 15, 2025
With this change, the payjoin directory's RFC 9540 compatible OHTTP
gateway additionally opts in to receiving OHTTP requests from arbitrary
relays.

See payjoin/ohttp-relay#58. 

Depends on
- #549
- #572
@spacebear21 spacebear21 mentioned this pull request Apr 1, 2025
17 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.

3 participants