Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser: OR in traverse not allowed #1250

Open
6 tasks done
zepatrik opened this issue Feb 21, 2023 · 0 comments
Open
6 tasks done

Parser: OR in traverse not allowed #1250

zepatrik opened this issue Feb 21, 2023 · 0 comments
Labels
bug Something is not working.

Comments

@zepatrik
Copy link
Member

Preflight checklist

Describe the bug

error from 18:88 to 18:90: expected ")", got "||"
        	            	
 16 |     view: (ctx: Context): boolean =>
 17 |       this.related.organization.traverse((o) => o.related.manager.includes(ctx.subject) || o.related.member.includes(ctx.subject)),
    |                                                                                         ^~                                         
 18 |   }

Reproducing the bug

Try parsing

import { Namespace, Context } from "@ory/permission-namespace-types"

class Organization implements Namespace {
  related: {
    member: Member[]
    manager: Member[]
  }
}

class Member implements Namespace {
  related: {
    organization: Organization[]
  }

  permits = {
    view: (ctx: Context): boolean =>
      this.related.organization.traverse((o) => o.related.manager.includes(ctx.subject) || o.related.member.includes(ctx.subject)),
  }
}

Workaround:

import { Namespace, Context } from "@ory/permission-namespace-types"

class Organization implements Namespace {
  related: {
    member: Member[]
    manager: Member[]
  }
}

class Member implements Namespace {
  related: {
    organization: Organization[]
  }

  permits = {
    view: (ctx: Context): boolean =>
      this.related.organization.traverse((o) => o.related.manager.includes(ctx.subject)) ||
      this.related.organization.traverse((o) => o.related.member.includes(ctx.subject)),
  }
}

Relevant log output

No response

Relevant configuration

No response

Version

network

On which operating system are you observing this issue?

Ory Network

In which environment are you deploying?

Ory Network

Additional Context

No response

@zepatrik zepatrik added the bug Something is not working. label Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working.
Projects
None yet
Development

No branches or pull requests

1 participant