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

Validating entities and permissions #726

Closed
pofider opened this issue Jun 8, 2020 · 1 comment
Closed

Validating entities and permissions #726

pofider opened this issue Jun 8, 2020 · 1 comment

Comments

@pofider
Copy link
Contributor

pofider commented Jun 8, 2020

Validating entities should skip permissions evaluation and should work across all entities.

For example, when validating entity name duplicity, we want to fail also when the current user doesn't have read permissions for another entity with the same name.

We could use req.context.skipAuthorizationForQuery for now and later find a more elegant way.

const q = {
      [humanReadableKey]: humanReadableValue
}
req.context.skipAuthorizationForQuery  = q
const existingEntity = await reporter.documentStore.collection(c).findOne(q, req)

However, we would need to handle also places outside authorization. In the version control, scheduling that blocks find for the none admin user. It needs to be discussed.

const col = reporter.documentStore.collection('versions')

col.beforeFindListeners.add('version-control', (q, p, req) => {
      if (req && req.context && req.context.user && !req.context.user.isAdmin && req.context.skipAuthorizationForQuery !== q) {
          throw reporter.authorization.createAuthorizationError(col.name)
        }
})

The original problem was reported here in the forum.

@pofider
Copy link
Contributor Author

pofider commented Nov 16, 2021

This work for some time...

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

No branches or pull requests

1 participant