Skip to content

Conversation

@Moumouls
Copy link
Member

@Moumouls Moumouls commented Oct 10, 2025

New Pull Request Checklist

Issue Description

Use express session system

Closes: #2759

Approach

Use express session

TODOs before merging

  • Add tests
  • Add changes to documentation (guides, repository pages, in-code descriptions)

Note

I checked that everything works in locla, login without and with Parse Dashboard users is working, session is correctly set in Cookies with HTTP only

Summary by CodeRabbit

  • Bug Fixes

    • Improved logout reliability by ensuring the process completes before redirecting.
    • Stabilized session handling with explicit cookie behavior for consistent user sessions.
    • Ensured flash messages are consistently available during authentication flows.
  • Chores

    • Updated authentication-related dependencies.
    • Replaced legacy session middleware with a more robust session implementation.

@parse-github-assistant
Copy link

I will reformat the title to use the proper commit message syntax.

@parse-github-assistant parse-github-assistant bot changed the title feat: update passport feat: Update passport Oct 10, 2025
@parse-github-assistant
Copy link

parse-github-assistant bot commented Oct 10, 2025

🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review.

@parseplatformorg
Copy link
Contributor

parseplatformorg commented Oct 10, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@coderabbitai
Copy link

coderabbitai bot commented Oct 10, 2025

📝 Walkthrough

Walkthrough

Replaced cookie-session with express-session in Parse-Dashboard/Authentication.js, moved connect-flash initialization after session middleware, made logout asynchronous using req.logout(callback), and updated package.json dependencies (removed cookie-session, added express-session, bumped passport).

Changes

Cohort / File(s) Change Summary
Authentication & session management
Parse-Dashboard/Authentication.js
Switched from cookie-session to express-session (configured name, secret, resave, saveUninitialized, cookie.maxAge, httpOnly, sameSite: 'lax'); initialized connect-flash after session middleware; updated logout to use req.logout(callback) and forward errors via next.
Dependencies
package.json
Removed [email protected]; added [email protected]; updated passport from 0.5.3 to 0.7.0.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant C as Client
  participant E as Express App
  participant S as express-session
  participant F as connect-flash
  participant P as Passport

  rect rgba(200,230,255,0.20)
    note over E,S: New middleware order: session -> flash -> passport
    C->>E: Request (login / protected)
    E->>S: session middleware (attach req.session)
    E->>F: flash middleware (attach req.flash)
    E->>P: Passport authenticate (reads/writes req.session)
    P-->>E: Auth result (user on req)
    E-->>C: Response (Set-Cookie if session created)
  end

  rect rgba(220,255,220,0.20)
    note over C,E: Logout (async)
    C->>E: POST /logout
    E->>P: req.logout(callback)
    alt success
      P-->>E: callback(null)
      E-->>C: 302 Redirect to login
    else error
      P-->>E: callback(error)
      E->>E: next(error)
    end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title Check ⚠️ Warning The current title claims a security upgrade of passport from 0.5.3 to 0.6.0, but the PR actually migrates the session middleware to express-session and bumps passport to 0.7.0, so it does not accurately or clearly describe the main change. Please revise the title to reflect the primary migration to express-session and the correct passport version, for example: “feat: migrate to express-session for authentication and bump passport to 0.7.0.”
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed The PR description adheres to the repository template by including the checklist, a clear issue description with a closing reference, an approach section, and a TODO list indicating that tests are added and documentation updates are pending, so it is mostly complete.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Moumouls
Copy link
Member Author

@mtrezza ready to review, i checked that everything works locally. So we remove the vulnerability warning of parse-dashboard

@uffizzi-cloud
Copy link

uffizzi-cloud bot commented Oct 10, 2025

Uffizzi Ephemeral Environment deployment-65584

⌚ Updated Oct 10, 2025, 15:15 UTC

☁️ https://app.uffizzi.com/github.com/parse-community/parse-dashboard/pull/3000

📄 View Application Logs etc.

What is Uffizzi? Learn more

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
package.json (1)

45-45: Session middleware added — plan for production store and cookie hardening

Good switch. For production, avoid the default MemoryStore; wire a store (Redis/Mongo/etc.) and ensure cookie options (secure/sameSite) are set in the middleware config in Authentication.js. Based on learnings

Parse-Dashboard/Authentication.js (2)

60-68: Optional: allow external session store via options

To avoid MemoryStore in production, accept options.sessionStore and pass it to express-session. Based on learnings

Apply:

-  app.use(require('express-session')({
+  app.use(require('express-session')({
     name: 'parse_dash',
     secret: cookieSessionSecret,
     resave: false,
     saveUninitialized: false,
+    store: options.sessionStore || undefined,
     cookie: {
       maxAge: cookieSessionMaxAge != null ? Number(cookieSessionMaxAge) : undefined,
       httpOnly: true,
       sameSite: 'lax',
       secure: 'auto'
     }
   }));

87-92: Logout should also destroy the session and clear cookie

req.logout removes req.user but leaves the session. Destroy it to prevent reuse, then redirect.

Apply:

-  app.get('/logout', function (req, res, next) {
-    req.logout(function (err) {
-      if (err) { return next(err); }
-      res.redirect(`${self.mountPath}login`);
-    });
-  });
+  app.get('/logout', function (req, res, next) {
+    req.logout(function (err) {
+      if (err) { return next(err); }
+      // Destroy session and clear cookie
+      if (req.session) {
+        req.session.destroy(() => {
+          res.clearCookie('parse_dash');
+          res.redirect(`${self.mountPath}login`);
+        });
+      } else {
+        res.clearCookie('parse_dash');
+        res.redirect(`${self.mountPath}login`);
+      }
+    });
+  });
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d3389f8 and aae634d.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (2)
  • Parse-Dashboard/Authentication.js (2 hunks)
  • package.json (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
Parse-Dashboard/Authentication.js (1)
Parse-Dashboard/server.js (2)
  • cookieSessionSecret (20-20)
  • cookieSessionMaxAge (22-22)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Docker linux/amd64
🔇 Additional comments (2)
Parse-Dashboard/Authentication.js (1)

60-68: Harden session cookie and coerce maxAge

  • In Parse-Dashboard/Authentication.js (lines 60–68), wrap cookieSessionMaxAge in Number() if it may be a string and add:
    httpOnly: true,
    sameSite: 'lax',
    secure: 'auto'
    
  • Verify app.set('trust proxy', 1) is enabled when running behind a proxy.
package.json (1)

60-60: Passport 0.7.0 upgrade — no legacy API usage found Verified that all req.logout calls use the callback syntax; no remaining req.login/logIn or cookie-session references.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aae634d and 54439d5.

📒 Files selected for processing (1)
  • Parse-Dashboard/Authentication.js (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
Parse-Dashboard/Authentication.js (1)
Parse-Dashboard/server.js (3)
  • app (160-160)
  • cookieSessionSecret (20-20)
  • cookieSessionMaxAge (22-22)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Docker linux/amd64
🔇 Additional comments (1)
Parse-Dashboard/Authentication.js (1)

88-93: LGTM! Async logout correctly implemented.

The logout handler correctly migrates to passport 0.7.0's asynchronous API, properly handling errors and redirecting only after successful logout.

@mtrezza
Copy link
Member

mtrezza commented Oct 14, 2025

@Moumouls is this a feature (i.e. any notable change for the dev / usr), or a fix due to the vulnerability?

@mtrezza
Copy link
Member

mtrezza commented Oct 14, 2025

@coderabbitai Suggest a PR title that describes the change in this PR and is according to angular commit convention.

@coderabbitai
Copy link

coderabbitai bot commented Oct 14, 2025

Tip

For best results, initiate chat on the files or code changes.

@mtrezza, based on the changes in this PR (migrating from cookie-session to express-session and updating Passport to address a vulnerability), here are my suggestions for PR titles following Angular commit convention:

Primary recommendation:

fix(security): migrate from cookie-session to express-session

Alternative options:

If emphasizing the authentication system change:

fix(auth): migrate to express-session for authentication

If emphasizing the dependency updates:

fix(deps): update passport and migrate to express-session

If this is considered more of a refactoring than a fix:

refactor(auth): migrate from cookie-session to express-session

Reasoning:

  • Using fix type because this PR addresses a security vulnerability warning mentioned by @Moumouls
  • The security or auth scope clearly indicates the area affected
  • The subject describes the main technical change (migration from cookie-session to express-session)
  • This is more descriptive than the current "feat: Update passport" which doesn't capture the primary change

Would you like me to adjust any of these suggestions?

@mtrezza mtrezza changed the title feat: Update passport fix: Security upgrade passport from 0.5.3 to 0.6.0 Oct 14, 2025
@mtrezza mtrezza merged commit fbb5e6d into parse-community:alpha Oct 14, 2025
11 checks passed
parseplatformorg pushed a commit that referenced this pull request Oct 14, 2025
# [7.6.0-alpha.9](7.6.0-alpha.8...7.6.0-alpha.9) (2025-10-14)

### Bug Fixes

* Security upgrade passport from 0.5.3 to 0.6.0 ([#3000](#3000)) ([fbb5e6d](fbb5e6d))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 7.6.0-alpha.9

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Oct 14, 2025
@Moumouls Moumouls mentioned this pull request Oct 24, 2025
2 tasks
parseplatformorg pushed a commit that referenced this pull request Nov 1, 2025
# [8.0.0](7.5.0...8.0.0) (2025-11-01)

### Bug Fixes

* Add missing major version increase of dashboard release ([#3005](#3005)) ([5debb4d](5debb4d))
* Cannot connect to server with error invalid header name ([#3006](#3006)) ([ea4ec07](ea4ec07))
* Currently displayed view reloads when editing and saving a different view ([#3002](#3002)) ([794a35a](794a35a))
* Dashboard config objects stored on server with public read / write access ([#2997](#2997)) ([31a4639](31a4639))
* ESC key does not cancel editing in data browser cell ([#3001](#3001)) ([d1d7241](d1d7241))
* Filter text field in data browser partly looses focus when hitting enter key to apply filter ([#2992](#2992)) ([e3085b9](e3085b9))
* Filter text field in data browser partly looses focus when selecting in drop-down element by hitting enter key to apply filter ([#2993](#2993)) ([f4c17c7](f4c17c7))
* Info panel briefly shows cached media content from previously selected cell when using pre-fetch ([#3008](#3008)) ([dd6a85e](dd6a85e))
* Missing alert when changing data browser browser data while rows are selected ([#2994](#2994)) ([6cabaa3](6cabaa3))
* Security upgrade parse from 3.5.1 to 7.0.1 ([#3003](#3003)) ([5123fbf](5123fbf))
* Security upgrade passport from 0.5.3 to 0.6.0 ([#3000](#3000)) ([fbb5e6d](fbb5e6d))
* Session management issue that causes malformed redirect URLs ([#3011](#3011)) ([1649dd3](1649dd3))
* Storing view on server creates view key with hashed view name instead of UUID ([#2995](#2995)) ([7cb65f3](7cb65f3))
* Switching between browser tabs can cause illegible text color for config parameter value field ([#3010](#3010)) ([77c5c67](77c5c67))
* View table data may be retained when switching between views ([#2996](#2996)) ([ddc91c9](ddc91c9))

### Features

* Add `matches regex` filter to data browser replacing limited `string contains string` filter ([#2991](#2991)) ([64a9f71](64a9f71))
* Add info panel options `prefetchImage`, `prefetchVideo`, `prefetchAudio` to pre-fetch media content in the info panel ([#3009](#3009)) ([6796c9e](6796c9e))
* Add Parse Server version compatibility detection ([#3004](#3004)) ([9a7a60f](9a7a60f))

### Performance Improvements

* Storing, deleting, modifying view in server storage now only affects the specific view instead of updating all views ([#2998](#2998)) ([48cea3c](48cea3c))

### BREAKING CHANGES

* This increases the required minimum version to Parse Server 7. ([5debb4d](5debb4d))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 8.0.0

@parseplatformorg parseplatformorg added the state:released Released as stable version label Nov 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state:released Released as stable version state:released-alpha Released as alpha version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants