From c5154cdad6211d3c08e7a594b7cf61629d9e2cb3 Mon Sep 17 00:00:00 2001 From: Paul Brussee Date: Fri, 9 Aug 2024 04:22:20 +0200 Subject: [PATCH] feat: allow to set a custom name for the csrf cookie (#801) (#864) --- 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 {