π The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.
Vue dockergolangkanbanknowledge-baseknowledge-managementmarkdownnote-takingnotesnotes-appnotionnuxtnuxtjsoffline-firstoidcpwaselfhostedssovuevuejswiki
Fix docker image allow unsecure cookies
Smaug67390c237c13b60e
diff --git a/.github/workflows/docker-image-deploy.yml b/.github/workflows/docker-image-deploy.ymlnew file mode 100644index 00000000..d6b9e9d5--- /dev/null+++ b/.github/workflows/docker-image-deploy.yml@@ -0,0 +1,47 @@+name: Build and Publish Docker Images++on:+ push:+ branches: [deploy]++jobs:+ build-and-push:+ runs-on: ubuntu-latest+ permissions:+ contents: read+ packages: write++ steps:+ - name: Checkout repository+ uses: actions/checkout@v4++ - name: Set lowercase repository name+ id: repo+ run: echo "repo_lc=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT++ - name: Log in to GitHub Container Registry+ uses: docker/login-action@v3+ with:+ registry: ghcr.io+ username: ${{ github.actor }}+ password: ${{ secrets.GITHUB_TOKEN }}++ - name: Build and push backend image+ uses: docker/build-push-action@v6+ with:+ context: ./backend+ push: true+ no-cache: true+ tags: |+ ghcr.io/${{ steps.repo.outputs.repo_lc }}-backend:latest+ ghcr.io/${{ steps.repo.outputs.repo_lc }}-backend:${{ github.ref_name }}++ - name: Build and push frontend image+ uses: docker/build-push-action@v6+ with:+ context: ./frontend+ push: true+ no-cache: true+ tags: |+ ghcr.io/${{ steps.repo.outputs.repo_lc }}-frontend:latest+ ghcr.io/${{ steps.repo.outputs.repo_lc }}-frontend:${{ github.ref_name }}diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image-release.ymlsimilarity index 100%rename from .github/workflows/docker-image.ymlrename to .github/workflows/docker-image-release.ymldiff --git a/backend/controllers/authentication.controller.go b/backend/controllers/authentication.controller.goindex 8e78c485..0226d11a 100644--- a/backend/controllers/authentication.controller.go+++ b/backend/controllers/authentication.controller.go@@ -85,8 +85,9 @@ 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, "/", os.Getenv("COOKIE_DOMAIN"), true, true)- c.SetCookie("RefreshToken", session.RefreshToken, ctr.app.Config.Auth.RefreshTokenExpiry, "/", os.Getenv("COOKIE_DOMAIN"), true, true)+ secure := shouldUseSecureCookies()+ c.SetCookie("Authorization", tokenString, ctr.app.Config.Auth.AccessTokenExpiry, "/", os.Getenv("COOKIE_DOMAIN"), secure, true)+ c.SetCookie("RefreshToken", session.RefreshToken, ctr.app.Config.Auth.RefreshTokenExpiry, "/", os.Getenv("COOKIE_DOMAIN"), secure, true)user.Password = ""go func() {@@ -141,8 +142,9 @@ 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, "/", os.Getenv("COOKIE_DOMAIN"), true, true)- c.SetCookie("RefreshToken", session.RefreshToken, ctr.app.Config.Auth.RefreshTokenExpiry, "/", os.Getenv("COOKIE_DOMAIN"), true, true)+ secure := shouldUseSecureCookies()+ c.SetCookie("Authorization", tokenString, ctr.app.Config.Auth.AccessTokenExpiry, "/", os.Getenv("COOKIE_DOMAIN"), secure, true)+ c.SetCookie("RefreshToken", session.RefreshToken, ctr.app.Config.Auth.RefreshTokenExpiry, "/", os.Getenv("COOKIE_DOMAIN"), secure, true)return http.StatusOK, "Session refreshed successfully."}@@ -170,8 +172,9 @@ 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, "/", os.Getenv("COOKIE_DOMAIN"), true, true)- c.SetCookie("RefreshToken", "", -1, "/", os.Getenv("COOKIE_DOMAIN"), true, true)+ secure := shouldUseSecureCookies()+ c.SetCookie("Authorization", "", -1, "/", os.Getenv("COOKIE_DOMAIN"), secure, true)+ c.SetCookie("RefreshToken", "", -1, "/", os.Getenv("COOKIE_DOMAIN"), secure, true)return http.StatusOK, "Logged out successfully."}@@ -192,8 +195,9 @@ func (ctr *Controller) LogoutAllDevices(c *gin.Context) (int, any) {if err := ctr.app.Services.Session.DeleteAllUserSessions(userId); err != nil {return http.StatusInternalServerError, errors.New("failed to delete sessions")}- c.SetCookie("Authorization", "", -1, "/", os.Getenv("COOKIE_DOMAIN"), true, true)- c.SetCookie("RefreshToken", "", -1, "/", os.Getenv("COOKIE_DOMAIN"), true, true)+ secure := shouldUseSecureCookies()+ c.SetCookie("Authorization", "", -1, "/", os.Getenv("COOKIE_DOMAIN"), secure, true)+ c.SetCookie("RefreshToken", "", -1, "/", os.Getenv("COOKIE_DOMAIN"), secure, true)return http.StatusOK, "Logged out from all devices successfully."}@@ -332,3 +336,8 @@ func deleteOldSessionsAndLogs(app *app.App) {fmt.Println("β Old sessions deleted successfully.")}}++func shouldUseSecureCookies() bool {+ value := os.Getenv("ALLOW_UNSECURE")+ return !(value == "true" || value == "1")+}diff --git a/docker-compose.yml b/docker-compose.ymlindex ea711d23..9246d3bf 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -68,6 +68,7 @@ services:DATABASE_NAME: alexandrieDATABASE_USER: alexandrieDATABASE_PASSWORD: password+ ALLOW_UNSECURE: 'true' # Set to 'true' if you run without HTTPS (e.g., local dev); in production, use 'false' and set up HTTPS# Application ConfigurationJWT_SECRET: your-secure-jwt-secret-key-change-this-in-production