Skip to content

πŸ“š The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

Fix cookie domain

Smaug673925e72c49aefa
diff --git a/backend/controllers/authentication.controller.go b/backend/controllers/authentication.controller.go
index 1869237e..003c4ffc 100644
--- a/backend/controllers/authentication.controller.go
+++ b/backend/controllers/authentication.controller.go
@@ -79,8 +79,8 @@ func (ctr *Controller) Login(c *gin.Context) (int, any) {
return http.StatusInternalServerError, errors.New("failed to create session")
}
- c.SetCookie("Authorization", tokenString, ctr.app.Config.Auth.AccessTokenExpiry, "/", "localhost", false, true)
- c.SetCookie("RefreshToken", session.RefreshToken, int(time.Duration(ctr.app.Config.Auth.RefreshTokenExpiry).Seconds()), "/", "localhost", false, true)
+ c.SetCookie("Authorization", tokenString, ctr.app.Config.Auth.AccessTokenExpiry, "/", os.Getenv("COOKIE_DOMAIN"), false, true)
+ c.SetCookie("RefreshToken", session.RefreshToken, int(time.Duration(ctr.app.Config.Auth.RefreshTokenExpiry).Seconds()), "/", os.Getenv("COOKIE_DOMAIN"), false, true)
user.Password = ""
go func() {
@@ -135,8 +135,8 @@ func (ctr *Controller) RefreshSession(c *gin.Context) (int, any) {
return http.StatusInternalServerError, errors.New("failed to update session")
}
- c.SetCookie("Authorization", tokenString, ctr.app.Config.Auth.AccessTokenExpiry, "/", "localhost", false, true)
- c.SetCookie("RefreshToken", session.RefreshToken, ctr.app.Config.Auth.RefreshTokenExpiry, "/", "localhost", false, true)
+ c.SetCookie("Authorization", tokenString, ctr.app.Config.Auth.AccessTokenExpiry, "/", os.Getenv("COOKIE_DOMAIN"), false, true)
+ c.SetCookie("RefreshToken", session.RefreshToken, ctr.app.Config.Auth.RefreshTokenExpiry, "/", os.Getenv("COOKIE_DOMAIN"), false, true)
return http.StatusOK, "Session refreshed successfully."
}
@@ -164,8 +164,8 @@ func (ctr *Controller) Logout(c *gin.Context) (int, any) {
if err = ctr.app.Services.Session.DeleteSession(session.Id); err != nil {
return http.StatusInternalServerError, errors.New("failed to delete session")
}
- c.SetCookie("Authorization", "", -1, "/", "localhost", false, true)
- c.SetCookie("RefreshToken", "", -1, "/", "localhost", false, true)
+ c.SetCookie("Authorization", "", -1, "/", os.Getenv("COOKIE_DOMAIN"), false, true)
+ c.SetCookie("RefreshToken", "", -1, "/", os.Getenv("COOKIE_DOMAIN"), false, true)
return http.StatusOK, "Logged out successfully."
}
diff --git a/ecosystem.config.js b/ecosystem.config.js
index 2d655382..e4532aa9 100644
--- a/ecosystem.config.js
+++ b/ecosystem.config.js
@@ -10,6 +10,7 @@ module.exports = {
MINIO_ENDPOINT: 'localhost:9000',
MINIO_BUCKET: 'alexandrie',
CPWD: './backend/',
+ COOKIE_DOMAIN: 'alexandrie-hub.fr',
},
},
{