mirror of
https://github.com/Direct-Dev-Ru/go-lcg.git
synced 2025-11-16 01:29:55 +00:00
Исправления в ветке main
This commit is contained in:
@@ -3,6 +3,7 @@ package serve
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"net/http"
|
||||
|
||||
@@ -92,6 +93,7 @@ func RenderLoginPage(w http.ResponseWriter, data LoginPageData) error {
|
||||
func getSessionID(r *http.Request) string {
|
||||
// Пытаемся получить из cookie
|
||||
if cookie, err := r.Cookie("session_id"); err == nil {
|
||||
fmt.Printf("[CSRF DEBUG] SessionID получен из cookie: %s\n", cookie.Value)
|
||||
return cookie.Value
|
||||
}
|
||||
|
||||
@@ -99,7 +101,12 @@ func getSessionID(r *http.Request) string {
|
||||
ip := r.RemoteAddr
|
||||
userAgent := r.Header.Get("User-Agent")
|
||||
|
||||
fmt.Printf("[CSRF DEBUG] SessionID не найден в cookie. Генерация нового на основе IP=%s, User-Agent (первые 50 символов): %s...\n",
|
||||
ip, safeSubstring(userAgent, 0, 50))
|
||||
|
||||
// Создаем простой хеш для сессии
|
||||
hash := sha256.Sum256([]byte(ip + userAgent))
|
||||
return hex.EncodeToString(hash[:])[:16]
|
||||
sessionID := hex.EncodeToString(hash[:])[:16]
|
||||
fmt.Printf("[CSRF DEBUG] Сгенерирован SessionID: %s\n", sessionID)
|
||||
return sessionID
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user