Skip to content

Commit

Permalink
fix: update setting cookie in
Browse files Browse the repository at this point in the history
  • Loading branch information
Björn Urban committed May 4, 2024
1 parent c81a7d7 commit 4f204cf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Embarking on a secure journey in Kubernetes.
- Node.js and npm
- Kubernetes cluster (for deployment)
- Helm (for deployment)
- traefik > 3.0

### Usage
add annotation `` to your ingress
Expand Down
13 changes: 13 additions & 0 deletions backend/internal/handlers/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,19 @@ func (h *Handler) HandleLogin(w http.ResponseWriter, r *http.Request) {
}

session, _ := store.Get(r, "session-cook")
tld, err := extractMainDomain(r.Host)
if err != nil {
sendJSONError(w, "Internal Server Error", http.StatusInternalServerError)
return
}
session.Options = &sessions.Options{
Path: "/", // Available across the entire domain
MaxAge: 3600, // Expires after 1 hour
HttpOnly: true, // Not accessible via JavaScript
Secure: true, // Only sent over HTTPS
SameSite: http.SameSiteNoneMode, // Controls cross-site request behavior
Domain: tld,
}
session.Values["authenticated"] = true
session.Values["user"] = inputUser.Email
session.Save(r, w)
Expand Down

0 comments on commit 4f204cf

Please sign in to comment.