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

Update MSRV for better compatibility #14

Merged
merged 5 commits into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@1.59.0
- run: cargo test --all-features
- uses: dtolnay/rust-toolchain@1.72.0
- run: cargo test --all-features
11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "actix-csrf"
version = "0.8.0"
authors = ["Edward Shen <[email protected]>", "Benoit Eudier <[email protected]>"]
edition = "2021"
rust-version = "1.72.0"
description = "CSRF middleware for Actix"
repository = "https://github.com/edward-shen/actix-csrf"
license = "MIT OR Apache-2.0"
Expand All @@ -11,18 +12,18 @@ categories = ["web-programming::http-server"]
include = ["src/**/*", "LICENSE-*", "README.md"]

[dependencies]
actix-web = { version = "4", default_features = false, features = [ "cookies" ] }
base64 = { version = "0.21.0", default_features = false, features = [ "std" ]}
actix-web = { version = "4.3.1", default-features = false, features = [ "cookies" ] }
base64 = { version = "0.21.0", default-features = false, features = [ "std" ]}
cookie = "0.16"
rand = { version = "0.8", features = [ "std_rng" ] }
tracing = "0.1"
serde = { version = "1", default_features = false }
serde = { version = "1", default-features = false }

[dev-dependencies]
# These versions are pinned to ensure compatibility with 4.0.0
anyhow = "1"
actix-web = { version = "=4.0.0", features = [ "cookies", "openssl"] }
actix-http = "=3.0.0"
actix-web = { version = "=4.3.1", features = [ "cookies", "openssl"] }
actix-http = "=3.3.1"
serde = { version = "1", features = [ "derive" ] }
tokio = { version = "1", features = [ "macros", "rt-multi-thread" ] }
openssl = { version = "0.10" }
Expand Down
2 changes: 1 addition & 1 deletion clippy.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
msrv = "1.59"
msrv = "1.72"
1 change: 0 additions & 1 deletion rust-toolchain

This file was deleted.

11 changes: 6 additions & 5 deletions src/extractor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ impl FromRequest for CsrfHeader {
.headers()
.get(header_name)
.map_or(Err(CsrfError::MissingCookie), |header| {
match header.to_str() {
Ok(header) => Ok(Self(CsrfToken(header.to_owned()))),
Err(_) => Err(CsrfError::MissingToken),
}
header
.to_str()
.map_or(Err(CsrfError::MissingToken), |header| {
Ok(Self(CsrfToken(header.to_owned())))
})
});

ready(resp)
Expand Down Expand Up @@ -165,7 +166,7 @@ impl CsrfCookieConfig {
Self { cookie_name }
} else {
Self {
cookie_name: format!("{}{}", prefix, cookie_name),
cookie_name: format!("{prefix}{cookie_name}"),
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
//! follows:
//!
//! - User submits a request for a resource that will directly send a CSRF token
//! (such as a login form). The server will respond with a `Set-Cookie` header
//! containing the CSRF token.
//! (such as a login form). The server will respond with a `Set-Cookie` header
//! containing the CSRF token.
//! - The user then submits a request that contains the CSRF token, either
//! through a custom header or in the request itself. This results in the client
//! sending the CRSF token twice: once as a cookie and once as a header or as
//! part of the request itself.
//! through a custom header or in the request itself. This results in the client
//! sending the CRSF token twice: once as a cookie and once as a header or as
//! part of the request itself.
//! - The server then validates if the CSRF value in the request is the same as
//! the CSRF value in the cookie. If it is, the request is allowed to proceed.
//! the CSRF value in the cookie. If it is, the request is allowed to proceed.
//!
//! This is why this process is known as a double-submit: You submit the CSRF
//! value to a CSRF protected endpoint in two different ways. For more
Expand Down Expand Up @@ -202,7 +202,7 @@ impl<Rng: TokenRng + SeedableRng> CsrfMiddleware<Rng> {
/// Creates a CSRF middleware with secure defaults. Namely:
///
/// - The CSRF cookie will be prefixed with `__Host-`. This also implies the
/// following:
/// following:
/// - `Secure` is set.
/// - `Domain` is _not_ set.
/// - `Path` is set to `/`.
Expand All @@ -222,7 +222,7 @@ impl<Rng: TokenRng> CsrfMiddleware<Rng> {
/// Namely:
///
/// - The CSRF cookie will be prefixed with `__Host-`. This also implies the
/// following:
/// following:
/// - `Secure` is set.
/// - `Domain` is _not_ set.
/// - `Path` is set to `/`.
Expand Down
Loading