If I have a GraphQL API looking like this:
type Query {
userById (id: ID): User
}
type User {
id: ID
name: String
secret: String
supervisor: Supervisor
}
type Supervisor {
id: ID
name: String
users: [User]
}
User X is logged in and triggers the legitimate query:
query {
userById (id: "X") {
name
secret
supervisor: {
name
}
}
}
He is authorized since he has access to his own User object.
But what if the user modifies the query to this:
query {
userById (id: "X") {
name
secret
supervisor: {
name
users {
secret
}
}
}
}
How can I secure users from fetching other users by traversing the graph. Specifically using Spring for GraphQL, https://spring.io/projects/spring-graphql. I also use Spring Security.