Skip to content
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

feat!: impersonate users #3042

Merged
merged 26 commits into from
Jul 15, 2023
Merged

feat!: impersonate users #3042

merged 26 commits into from
Jul 15, 2023

Conversation

sr258
Copy link
Member

@sr258 sr258 commented Jul 9, 2023

This PR implements the functionality to display other users' user states and to set the user state to read only.

The old permission system was replaced to simplify permission handling.: It had 'grown naturally' and needed an overhaul.

Issues with the old system were:

  • The IUser interface included some permissions (e.g. if users can update libraries). The library expected these permissions to be loaded whenever the user object is passed to the library. This means that all permissions need to be loaded on authentication, even if they are never needed. This approach only allowed user-specific permissions.
  • The only other place where there was authorization was in the Mongo/S3 storage classes. You were able to pass in a callback function that authorized users. This means authorization was specific to the storage classes. This is not great, as the file-based storage classes didn't have authorization and would lead to redundancy if they included it. Authorization logic should also not be part of a storage driver (separation of concerns, duplication)
  • The authorization in the Mongo/S3 classes only allowed for lists of permissions to be returned for contentIds and users. This means that you might have to perform complex queries to get the lists, even if you never need them.
  • The user data system didn't have any proper authorization at all.

Now, it's the job of the manager objects to implement permission checks and not of the storage classes. That means all storage classes are now capable of working in a permission system and not just the S3 classes. There's also a single interface IPermissionSystem that implementations can pass into the H5PEditor or H5PPlayer constructors to have fine-grained control over who can do what.

return res
.status(500)
.send(
`Error deleting content with id ${req.params.contentId}: ${error.message}`

Check warning

Code scanning / CodeQL

Reflected cross-site scripting Medium

Cross-site scripting vulnerability due to a
user-provided value
.
res.send(`Content ${req.params.contentId} successfully deleted.`);
res.status(200).end();
res.status(200).send(
`Content ${req.params.contentId} successfully deleted.`

Check warning

Code scanning / CodeQL

Reflected cross-site scripting Medium

Cross-site scripting vulnerability due to a
user-provided value
.
return res
.status(500)
.send(
`Error deleting content with id ${req.params.contentId}: ${error.message}`

Check warning

Code scanning / CodeQL

Exception text reinterpreted as HTML Medium

Exception text
is reinterpreted as HTML without escaping meta-characters.
@coveralls
Copy link

coveralls commented Jul 9, 2023

Coverage Status

coverage: 65.208% (-0.6%) from 65.805% when pulling f88323c on feat/permission-system into 3bb30a3 on master.

@sr258 sr258 marked this pull request as ready for review July 15, 2023 12:29
: undefined
}
);
res.send(content);
res.status(200).end();
res.status(200).send(content);

Check warning

Code scanning / CodeQL

Reflected cross-site scripting Medium

Cross-site scripting vulnerability due to a
user-provided value
.
res.status(500).end(error.message);
console.error(error);
res.status(error.httpStatusCode ? error.httpStatusCode : 500).send(
error.message

Check warning

Code scanning / CodeQL

Exception text reinterpreted as HTML Medium

Exception text
is reinterpreted as HTML without escaping meta-characters.
@sr258 sr258 merged commit 75d7b68 into master Jul 15, 2023
2 checks passed
@sr258 sr258 deleted the feat/permission-system branch September 1, 2023 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants