os-js / osjs-server

OS.js Server Module

Home Page:https://manual.os-js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue when accessing permissioned mountpoint

josephjeno opened this issue · comments

When attempting to access a mountpoint with group permissioning on startup, I recieve the below error:

TypeError: Cannot read property 'indexOf' of undefined
at arr.every.g (C:\Users\JJeno\Documents\GitHub\webgs\node_modules@osjs\server\src\utils\vfs.js:76:62)
at Array.every ()
at validateAll (C:\Users\JJeno\Documents\GitHub\webgs\node_modules@osjs\server\src\utils\vfs.js:76:43)
at validateNamedGroups (C:\Users\JJeno\Documents\GitHub\webgs\node_modules@osjs\server\src\utils\vfs.js:86:7)
at validateGroups (C:\Users\JJeno\Documents\GitHub\webgs\node_modules@osjs\server\src\utils\vfs.js:108:24)
at C:\Users\JJeno\Documents\GitHub\webgs\node_modules@osjs\server\src\utils\vfs.js:138:9
at Object.realpath (C:\Users\JJeno\Documents\GitHub\webgs\node_modules@osjs\server\src\vfs.js:128:62)

The error goes away by adding the relevant group permission as below:

    // Creates shared directory if doesn't exist
    this.core.make('osjs/vfs')
      .realpath('shared:/', { groups: ['webce'] })
      .then(realpath => fs.ensureDir(realpath))

The issue seems to be related to req.session.user not existing during checkMountpointPermission().

The reason this happens is that when interacting directly with the VFS APIs, you're sort of sending a custom built HTTP request to the filesystem handler, however this request does not contain a session cookie (or any identifier), leading to blank session data.

The second argument on the realpath() method will fill the session data.

Ideally the server should assign some default properties to the object, here:

https://github.com/os-js/osjs-server/blob/master/src/filesystem.js#L170

3.0.48 is now out which should resolve this issue.