CsrfMiddleware class
CSRF Protection Middleware using Double Submit Cookie pattern
Generates and validates CSRF tokens to prevent Cross-Site Request Forgery attacks.
Example usage:
final csrfMiddleware = CsrfMiddleware(secretKey: 'your-secret-key-here');
final handler = Pipeline()
.addMiddleware(csrfMiddleware.middleware())
.addHandler(router);
Constructors
Properties
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
safeMethods
→ List<
String> -
final
- secretKey → String
-
final
- tokenExpiry → Duration
-
final
- tokenName → String
-
final
Methods
-
middleware(
) → Middleware - Creates the CSRF middleware
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited