cel-spec | Common Expression Language -- specification and binary | Parser library
kandi X-RAY | cel-spec Summary
kandi X-RAY | cel-spec Summary
Common Expression Language -- specification and binary representation
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of cel-spec
cel-spec Key Features
cel-spec Examples and Code Snippets
Community Discussions
Trending Discussions on cel-spec
QUESTION
I need to store in Firebase informations about 2 users, that need to be properly secured against read by other users.
Example :
...ANSWER
Answered 2020-Aug-10 at 14:57As mentioned by @DougStevenson and myself on the comments the best approach would be to duplicate the data in more than one document for the following reasons:
Data Duplication is a common and at times recommended practice for NoSQL databases.
The second approach would no be possible with the current logic for
contains
in the firebase rules and the very fact that you are storing both uid concatenated is in itself a form of data duplication.
QUESTION
I would like to filter the resources available for a user based on their name. So I tried to use GCP IAM Role conditions.
But the only function which seems to be available on resource.name are startsWith(), endsWith() or extract(), saying the linter and the example I found. In the CEL language definition (https://github.com/google/cel-spec/blob/master/doc/langdef.md) contains() or matches() exists but I cannot use it in GCP console, the linter refuse it.
To be clear on the context the same project holds resources for production and non production environments and I would like to give rights to people without giving them access to production ones. The production resources are named with a pattern -prod-.
Is there another way to set an IAM Role condition based on part of resources name?
...ANSWER
Answered 2020-Apr-16 at 17:10If we look at the reference documentation for IAM conditions ... specifically the attribute references found here:
https://cloud.google.com/iam/docs/conditions-attribute-reference
we find that for each entry, there is a set of "supported operators". It appears that only those operators are the ones supported.
For example, if we look at the resource.name attribute we see that it lists:
- startsWith
- endsWith
- extract
- ==
- !=
What this seems to tell me is that the operators are explicitly defined and it isn't just the linter but the actual spec that is restricting what can be done. Best we can likely do is raise a feature request with Google for some future enhancement.
QUESTION
In our Firebase setup we store the user's role in custom claims. And so, in our Cloud Firestore security rules we need to evaluate whether the user has the appropriate role to perform an action. So I created the function getRole
which conveniently gets the requested value from the user's auth token. However, there are certain edge cases when the user does not yet have a role, and in those cases I want their role to evaluate to the lowest possible security role, in our case this is just "user"
. I read the language spec for CEL (Common Expression Language) which is what this rule language is based on and it does in fact support a ternary operator. (Doc). So I went and plugged in this code into my Firestore security rules and the online editor validated the rules and accepted my new rules. However, I later found that locally, when running my security rules unit tests and also loading up the rules in the firebase emulators, I get this error:
ERROR Use of ternary operator not allowed
So either the production Firestore rules support the ternary operator and the local emulators do not, or the production one is validating against CEL and passing validation when they should not.
At any rate, I would like to safely be able to have a function which returns the actual value of the user's role, or a default safe value if it is not set.
Please note that we have tried to omit the 'role' in getCustomClaims()
statement and it blows up if the key does not exist in the custom claims.
ANSWER
Answered 2020-Feb-13 at 22:53You can make this work without a ternary operator. You can see that, from the rules API documentation, that request.auth.token
is a map type object. The API docs for Map says that there is a method called get() which accepts a default ("safe") value to return if the passed key isn't found:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install cel-spec
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page