这是indexloc提供的服务,不要输入任何密码
Skip to content

Handling multiple roles on the graphql client (possibly in the same query) #877

@revskill10

Description

@revskill10
  • In an application, one user often have multi roles at the same time, at a screen.
    Let's say, in a blog application, both editor and author could edit a post. So if a user is both an editor and an author, how to authenticate with hasura then ?
    In this case, hasura should support multi-roles in headers: x-hasura-roles instead of x-hasura-role.
    Else how do you decide which role the user should use ? Because all roles are equal and valid.

  • What i mean by multi-roles query is that.

query {
table1 {
 field1
}
table2 {
 field2
}

Suppose that user has roles role1 for table1, and role2 for table2 .
This is currently impossible to make above query.

  • OK, what's if a websocket connection is made by above query. Now the user's role changed, what happen ?
    The websocket connection should not be recreated for that. Instead the subscription data should reflect the change after that.

And this is the second hard part to solve this problem (when roles change for a subscription query)

  • Suggested implementation (per @coco98 )
    The query now should look like this
query {
  asUser {
    someTable {...}
  }
  asManager {
    someTable {...}
  }
}

Note 2 : My proposed solution

In Console UI for permission setting, there must be ability to assign current permission to another roles in system (or creation new role).
Only then that, Hasura could validate one role or array of roles query to resolve correct data to return.

Metadata

Metadata

Labels

c/serverRelated to servere/hardWill take weeks of effortk/enhancementNew feature or improve an existing featurep/highcandidate for being included in the upcoming sprinttriage/4-rfc-publishedThe RFC is published and comments are requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions