You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been using this library for a while now and just ran into an issue where my rules are not working in my application, but the Cerbos tests are working fine.
The Principal and Resource have exactly the same values in both the tests and my real world situation, but for some reason when I pass my principal to the isAllowed-function of the Cerbos client, attributes that are not simple types (like numbers, booleans or strings) appear stringified in the decision audit logs.
I'm pretty sure the real-world case fails, because the rules cannot be correctly evaluated based on the stringified values, instead of the expected Objects/Arrays.
For Example:
I'm requesting a resource, that requires my user to have certain claims/attributes. The rule might look something like this:
We can see that the claims have been stringified and all "-characters have been escaped inside the array. It works for the roles, so it seems to be an issue with Object or Array type fields inside the attributes. I included the resource in the last payload as well, because the same issue exists for Object or Array type attributes in the Resources.
The text was updated successfully, but these errors were encountered:
Hi!
I've been using this library for a while now and just ran into an issue where my rules are not working in my application, but the Cerbos tests are working fine.
The Principal and Resource have exactly the same values in both the tests and my real world situation, but for some reason when I pass my principal to the
isAllowed
-function of the Cerbos client, attributes that are not simple types (like numbers, booleans or strings) appear stringified in the decision audit logs.I'm pretty sure the real-world case fails, because the rules cannot be correctly evaluated based on the stringified values, instead of the expected Objects/Arrays.
For Example:
I'm requesting a resource, that requires my user to have certain claims/attributes. The rule might look something like this:
As I said the Cerbos tests all pass. Principal for my Cerbos tests looks like this:
Now, when I use it in my real world application, I have a helper function that transforms the requesting users Identity to the principal format:
I printed the identity that is returned from said function and I pass this value as-is to the
isAllowed
-function:As we can see the claims are an array of strings, as they should be.
But when I check the decision logs of Cerbos, I get the following:
We can see that the claims have been stringified and all "-characters have been escaped inside the array. It works for the roles, so it seems to be an issue with Object or Array type fields inside the attributes. I included the resource in the last payload as well, because the same issue exists for Object or Array type attributes in the Resources.
The text was updated successfully, but these errors were encountered: