@@ -12,6 +12,8 @@ import (
1212 "os"
1313 "time"
1414
15+ "github.com/gofiber/fiber/v3/extractors"
16+
1517 "github.com/gofiber/fiber/v3"
1618 "github.com/gofiber/fiber/v3/middleware/csrf"
1719 "github.com/gofiber/fiber/v3/middleware/session"
@@ -86,8 +88,8 @@ func main() {
8688
8789 // Initialize a session store
8890 sessConfig := session.Config {
89- IdleTimeout : 30 * time .Minute , // Expire sessions after 30 minutes of inactivity
90- Extractor : session .FromCookie ("__Host-session" ), // Recommended to use the __Host- prefix when serving the app over TLS
91+ IdleTimeout : 30 * time .Minute , // Expire sessions after 30 minutes of inactivity
92+ Extractor : extractors .FromCookie ("__Host-session" ), // Recommended to use the __Host- prefix when serving the app over TLS
9193 CookieSecure : true ,
9294 CookieHTTPOnly : true ,
9395 CookieSameSite : "Lax" ,
@@ -123,11 +125,11 @@ func main() {
123125 // Configure the CSRF middleware
124126 csrfConfig := csrf.Config {
125127 Session : store ,
126- Extractor : csrf .FromForm ("csrf" ), // In this example, we will be using a hidden input field to store the CSRF token
127- CookieName : "__Host-csrf" , // Recommended to use the __Host- prefix when serving the app over TLS
128- CookieSameSite : "Lax" , // Recommended to set this to Lax or Strict
129- CookieSecure : true , // Recommended to set to true when serving the app over TLS
130- CookieHTTPOnly : true , // Recommended, otherwise if using JS framework recomend: false and Extractor: csrf.FromHeader(" X-CSRF-Token")
128+ Extractor : extractors .FromForm ("csrf" ), // In this example, we will be using a hidden input field to store the CSRF token
129+ CookieName : "__Host-csrf" , // Recommended to use the __Host- prefix when serving the app over TLS
130+ CookieSameSite : "Lax" , // Recommended to set this to Lax or Strict
131+ CookieSecure : true , // Recommended to set to true when serving the app over TLS
132+ CookieHTTPOnly : true , // Recommended, otherwise if using JS framework recomend: false and KeyLookup: "header: X-CSRF-Token"
131133 ErrorHandler : csrfErrorHandler ,
132134 IdleTimeout : 30 * time .Minute ,
133135 }
0 commit comments