-
Notifications
You must be signed in to change notification settings - Fork 55
Closed
Description
We have a need to restrict the tables, rows and columns that are returned based on the calling user.
It's straightforward to authenticate the user using Spring; then the user's roles and an @Entity representing the user in a table in the db are available in the SecurityContext.
Examples of business rules:
- Only users with 'ADMIN' role can access the table/entity 'audit_log'
- Rows in the 'user' table can only be returned or traversed if user.id == user's id, or if the user has the 'ADMIN' role. But ADMINs cannot see some columns e.g. the user's real name.
- Rows in 'user_content' are available where creator_id is the current user's id, or where there is a row in the 'friends' table with both users' ids on. But friends don't see 'user_content.private_notes'
What are the options for defining/expressing these rules? Is there an existing GraphQL, JPA or SQL way of doing this?
Thoughts:
- Annotations on the JPA classes. I'm not sure they can be expressive enough without getting messy.
- Entity graphs?
- JPA criteria for each table - would provide table and row level access but not projection
- Interface/method on the JPA class?
Next, how could we hook this in to graphql-jpa-query to filter values as they are queried?
- amending the JPA query as it is built?
- graphql directives?
lefuturiste
Metadata
Metadata
Assignees
Labels
No labels