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

access control: how to use "_in" with x-hasura-allowed-roles or other session variables in permissions #1314

@sulliwane

Description

@sulliwane

version: alpha34

Here is my jwtoken:

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwczovL2hhc3VyYS5pby9qd3QvY2xhaW1zIjp7IngtaGFzdXJhLWFsbG93ZWQtcm9sZXMiOlsiYWRtaW4iLCJ1c2VyIl0sIngtaGFzdXJhLWRlZmF1bHQtcm9sZSI6InVzZXIiLCJ4LWhhc3VyYS11c2VyLWlkIjoiMSJ9LCJpYXQiOjE1NDY2MDY5MzR9.-dfaH0ZG8gXbSMUn_m8LMkKdEdAk7NauqQqhI_yBnS0

which payload in clear is:

{
  "https://hasura.io/jwt/claims": {
    "x-hasura-allowed-roles": [
      "admin",
      "user"
    ],
    "x-hasura-default-role": "user",
    "x-hasura-user-id": "1"
  },
  "iat": 1546606934
}

In the console, permission tab, I'm setting this:
screenshot from 2019-01-04 16-28-34

{"role":{"_in":["X-HASURA-ALLOWED-ROLES"]}}

But obviously it dosn't work.

On the other hand, using {"role":{"_eq":["X-HASURA-ROLE"]}} works (but if user has multiple roles, using this permission only get me back data for the current role. I'd like to get data related to all user roles).

I'm I missing something on how to use arrays? Many Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions