Skip to content

ScopeAuth Plugin - Prevent User From Accessing Other Group's Data #845

Answered by hayes
arimgibson asked this question in Q&A
Discussion options

You must be logged in to vote

Generally having auth enforced as part of your queries so content the user isn't authorized for is never loaded is ideal (adding conditions to your where clause). Pothos doesn't really provide anything that helps with this though.

There isn't a good way to global define and enforce these rules across multiple objects, because Pothos doesn't really understand the relations between the different objects in a way that would allow knowing if a particular relation denotes ownership/access.

What you can do share/simplify how the auth scope for organizations is defined:

You can create a scope like accessOrganization: string, that does something like

authScopes: (ctx) => ({
  accessOrganization: (id

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@arimgibson
Comment options

Answer selected by arimgibson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants