mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 07:56:16 -04:00
Fix read only pad access with authentication
Before this commit, webaccess.checkAccess saved the authorization in user.padAuthorizations[padId] with padId being the read-only pad ID, however later stages, e.g. in PadMessageHandler, use the real pad ID for access checks. This led to authorization being denied. This commit fixes it by only storing and comparing the real pad IDs and not read-only pad IDs. This fixes test case "authn user readonly pad -> 200, ok" in src/tests/backend/specs/socketio.js.
This commit is contained in:
parent
0d33793908
commit
3c71e8983b
4 changed files with 28 additions and 19 deletions
|
@ -218,17 +218,9 @@ exports.handleMessage = async (socket, message) => {
|
|||
return;
|
||||
}
|
||||
|
||||
// check if pad is requested via readOnly
|
||||
let padId = auth.padID;
|
||||
|
||||
if (padId.indexOf('r.') === 0) {
|
||||
// Pad is readOnly, first get the real Pad ID
|
||||
padId = await readOnlyManager.getPadId(padId);
|
||||
}
|
||||
|
||||
const {session: {user} = {}} = socket.client.request;
|
||||
const {accessStatus, authorID} =
|
||||
await securityManager.checkAccess(padId, auth.sessionID, auth.token, user);
|
||||
await securityManager.checkAccess(auth.padID, auth.sessionID, auth.token, user);
|
||||
if (accessStatus !== 'grant') {
|
||||
// Access denied. Send the reason to the user.
|
||||
socket.json.send({accessStatus});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue