Skip to content

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

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

Closed
CollinKempkes opened this issue Feb 12, 2025 · 3 comments
Closed

Comments

@CollinKempkes
Copy link

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
@ymc9
Copy link
Member

ymc9 commented Feb 16, 2025

Thanks for filing this @CollinKempkes . I agree it's useful to support such usage. Is it blocking you now?

@CollinKempkes
Copy link
Author

Totally not, we can do some workarounds for this behaviour, but thanks for asking! :)

@ymc9
Copy link
Member

ymc9 commented Mar 24, 2025

Fixed in 2.13.0

@ymc9 ymc9 closed this as completed Mar 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants