Files
uPortal2/backend/internal/csrf/handler.go
T

21 lines
414 B
Go
Raw Normal View History

2026-10-21 13:17:44 +03:00
package csrf
import (
"net/http"
)
func UpdateCsrf(w http.ResponseWriter, cookieName string, secure bool) (string, error) {
cookieValue, err := generateToken(CsrfLength)
if err != nil {
return "", err
}
http.SetCookie(w, &http.Cookie{
Name: cookieName,
Value: cookieValue,
Path: "/",
HttpOnly: false,
Secure: secure,
SameSite: http.SameSiteLaxMode,
})
return cookieValue, nil
}