Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package config

import (
"fmt"
"net/http"
"os"
"strconv"
"strings"
Expand All @@ -20,6 +21,7 @@ type Config struct {
RateLimit RateLimitConfig
CORS CORSConfig
SecurityHeaders SecurityHeadersConfig
Cookie CookieConfig
}

type ServerConfig struct {
Expand Down Expand Up @@ -78,6 +80,11 @@ type SecurityHeadersConfig struct {
XSSProtection string
}

type CookieConfig struct {
Secure bool
SameSite http.SameSite
}

func Load() (*Config, error) {
config := &Config{
Server: ServerConfig{
Expand Down Expand Up @@ -136,6 +143,10 @@ func Load() (*Config, error) {
ReferrerPolicy: getEnv("SECURITY_REFERRER_POLICY", "strict-origin-when-cross-origin"),
XSSProtection: getEnv("SECURITY_XSS_PROTECTION", "1; mode=block"),
},
Cookie: CookieConfig{
Secure: false,
SameSite: http.SameSiteNoneMode,
},
}

if err := config.Validate(); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/http/auth_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func NewAuthHandlers(authService services.AuthService, logger *logger.Logger, cf
}

func (h *AuthHandlers) getCookieSettings() (secure bool, sameSite http.SameSite) {
return false, http.SameSiteDefaultMode
return h.config.Cookie.Secure, h.config.Cookie.SameSite
}

func (h *AuthHandlers) setSecureCookie(w http.ResponseWriter, name, value string, maxAge int) {
Expand Down