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(extract): prefixed signed&private cookies #3251

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

andrzejSulkowski
Copy link

@andrzejSulkowski andrzejSulkowski commented Mar 6, 2025

closes #3246

Cookie Prefixes Support

Motivation

Cookie prefixes (__Host- and __Secure-) are a web security feature that help protect against cookie manipulation and session fixation attacks. This PR enhances Axum's cookie handling by adding proper support for cookie prefixes across all cookie jar types (CookieJar, SignedCookieJar, and PrivateCookieJar).

Solution

This PR implements:

  • Support for cookie prefixes with correct attribute enforcement (e.g., Secure flag, Path=/) using the underlying cookie crate's PrefixedJar
  • Consistent prefix handling methods (add_prefixed, get_prefixed, remove_prefixed) for all cookie jar types
    Integration of prefix support with signed and private cookies, ensuring the encryption/signing is maintained
  • Extended cookie tests to verify cookie encryption/signing rather than plain-text value matching

@andrzejSulkowski andrzejSulkowski marked this pull request as draft March 6, 2025 17:16
@andrzejSulkowski andrzejSulkowski marked this pull request as ready for review March 7, 2025 05:57
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.

[axum-extra] Cookie Name Prefixes
1 participant