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

[axum-extra] Cookie Name Prefixes #3246

Open
1 task done
teohhanhui opened this issue Mar 4, 2025 · 5 comments · May be fixed by #3251
Open
1 task done

[axum-extra] Cookie Name Prefixes #3246

teohhanhui opened this issue Mar 4, 2025 · 5 comments · May be fixed by #3251

Comments

@teohhanhui
Copy link

teohhanhui commented Mar 4, 2025

  • I have looked for existing issues (including closed) about this

Feature Request

Motivation

Cookie Name Prefixes is defined in the draft RFC6265bis (HTTP WG draft).

It is supported by all modern browsers: https://caniuse.com/mdn-http_headers_set-cookie_cookie_prefixes

Proposal

cookie has https://docs.rs/cookie/latest/cookie/prefix/struct.PrefixedJar.html - can it be used somehow?

Alternatives

Manually doing all this is error prone...

@andrzejSulkowski
Copy link

I'd be happy to tackle this one. It’ll be my first pull request for this repository, so I might appreciate some guidance along the way.

@mladedav
Copy link
Collaborator

mladedav commented Mar 4, 2025

I guess it can be used directly by extracting CookieJar as usual and then using prefixed_mut on that. I don't see how that would be error prone, but maybe I'm missing something?

I don't think we can have an extractor for PrefixedJar itself since it has a lifetime parameter dependant on the parent CookieJar. But you could maybe create a wrapper around it to just expose the prefixed jar and not the parent one.

Try to look inside the cookie directory in axum-extra and feel free to create a draft based on that, we can then iterate on that in the PR.

@teohhanhui
Copy link
Author

@mladedav axum_extra::extract::cookie::CookieJar doesn't expose the wrapped CookieJar: https://docs.rs/axum-extra/latest/axum_extra/extract/cookie/struct.CookieJar.html

So what you've suggested is not possible for users, unless I'm missing something really obvious.

@mladedav
Copy link
Collaborator

mladedav commented Mar 5, 2025

Sorry, I didn't realize these are two distinct types.

Then we can expose the wrapped prefix jars from the wrapper too in a similar manner to what the upstream crate does. Or do you think having an extractor that already resolves to a prefix jar would be better?

@teohhanhui
Copy link
Author

teohhanhui commented Mar 5, 2025

In my use case, I actually need to omit the __Host- prefix when on localhost, because of a Chromium bug: https://issues.chromium.org/issues/40196122

So I think the method should be exposed, even if PrefixedJar were to be made available separately as an extractor. (Also, we need to consider cases of SignedCookieJar / PrivateCookieJar combined with PrefixedJar...)

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 a pull request may close this issue.

3 participants