Refactoring for Gin, NoSurf and SCS continues.
This commit is contained in:
21
internal/platform/csrf/csrf.go
Normal file
21
internal/platform/csrf/csrf.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package csrf
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"synlotto-website/internal/platform/config"
|
||||
|
||||
"github.com/justinas/nosurf"
|
||||
)
|
||||
|
||||
func Wrap(h http.Handler, cfg config.Config) http.Handler {
|
||||
cs := nosurf.New(h)
|
||||
cs.SetBaseCookie(http.Cookie{
|
||||
Name: cfg.CSRF.CookieName,
|
||||
Path: "/",
|
||||
HttpOnly: true,
|
||||
Secure: cfg.HttpServer.ProductionMode,
|
||||
SameSite: http.SameSiteLaxMode,
|
||||
})
|
||||
return cs
|
||||
}
|
||||
Reference in New Issue
Block a user