Skip to content

Functions typings are not supporting execution of functions as input #1984

Closed
@CollinKempkes

Description

@CollinKempkes

Description and expected behavior
Access policy string functions do not accept execution of function as input.

I want to create a policy like this:

  @@allow('all', 
    auth().restrictions?[
      scopes?[contains(policy_name, currentModel())  && endsWith(policy_name, currentOperation())
    ]]
  )

As our policies looks like this entityName:action, but contains, endsWith and other helper functions are not working with an execute of a function as input. The error says: second argument must be a literal, an enum, an expression starting with 'auth().', or an array of them. But I guess in this case it is the same thing as currentModel and currentOperation are having a string as a return type.

context:
these are the function definitions for currentModel() and currentOperation().

function currentModel(casing: String?): String {
} @@@expressionContext([AccessPolicy])

function currentOperation(casing: String?): String {
} @@@expressionContext([AccessPolicy])

Environment (please complete the following information):

  • ZenStack version: 2.11.6
  • Prisma version: 6.3.1
  • Database type: Postgresql

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