From d984022af5af97cba1ced255a93604b17b539251 Mon Sep 17 00:00:00 2001
From: Paul Brussee
Date: Wed, 7 Aug 2024 22:42:05 +0200
Subject: [PATCH] feat: allow to set a custom name for the csrf cookie (#801)
---
poem/src/middleware/csrf.rs | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/poem/src/middleware/csrf.rs b/poem/src/middleware/csrf.rs
index 63b3e87731..6c98f1dacf 100644
--- a/poem/src/middleware/csrf.rs
+++ b/poem/src/middleware/csrf.rs
@@ -104,6 +104,15 @@ impl Csrf {
Default::default()
}
+ /// Sets the name of the csrf cookie. Default is `poem-csrf-token`.
+ #[must_use]
+ pub fn cookie_name(self, value: impl Into) -> Self {
+ Self {
+ cookie_name: value.into(),
+ ..self
+ }
+ }
+
/// Sets AES256 key to provide signed, encrypted CSRF tokens and cookies.
#[must_use]
pub fn key(self, key: [u8; 32]) -> Self {