-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
feat: make cookie names configurable with prefix setting #7450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7d61c58
146c2e1
fb66edc
ef25e75
22a0c6d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,16 @@ | ||
| 'use strict'; | ||
| const securityManager = require('./db/SecurityManager'); | ||
| import settings from './utils/Settings'; | ||
|
|
||
| // checks for padAccess | ||
| module.exports = async (req: { params?: any; cookies?: any; session?: any; }, res: { status: (arg0: number) => { (): any; new(): any; send: { (arg0: string): void; new(): any; }; }; }) => { | ||
| const {session: {user} = {}} = req; | ||
| const p = settings.cookie.prefix; | ||
| const accessObj = await securityManager.checkAccess( | ||
| req.params.pad, req.cookies.sessionID, req.cookies.token, user); | ||
| req.params.pad, | ||
| req.cookies[`${p}sessionID`] || req.cookies.sessionID, | ||
| req.cookies[`${p}token`] || req.cookies.token, | ||
|
Comment on lines
+8
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1. sessionid still default cookie Because settings.cookie.prefix defaults to '', Etherpad still relies on the generic sessionID cookie name by default, which keeps default deployments prone to collisions with other web frameworks. This violates the requirement to avoid sessionID as the default cookie name. Agent Prompt
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed — cookie prefix is now validated to only allow [a-zA-Z0-9_-] characters, preventing header injection. |
||
| user); | ||
|
Comment on lines
+8
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1. Foreign token blocks access In pad access checks, when cookie.prefix is set the code falls back to the unprefixed token cookie without validating it, so a conflicting token cookie from another app can cause SecurityManager.checkAccess() to deny with “invalid author token”. This defeats the purpose of enabling a prefix and can break direct /import and /export requests with unexpected 403s until the client creates the prefixed cookie. Agent Prompt
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Won't fix — with default prefix |
||
|
|
||
| if (accessObj.accessStatus === 'grant') { | ||
| // there is access, continue | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.