-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add a ternary conditional operator function #13
Comments
I support this. My typical use case is when the attribute values are strings representing levels of something and you want to map them to integers in order to compare them. For example, say we have a subject attribute 'clearance_level' and resource attribute 'classification_level'. Both may take string values "RESTRICTED", "CONFIDENTIAL", "SECRET" which represent levels of classification/clearance in ascending order ("RESTRICTED" is lower than "CONFIDENTIAL", etc.); and we want the policy to return Permit if one of the subject's clearance levels is greater than or equal to the resource's classification level. If we map these values to integers (RESTRICTED -> 1, CONFIDENTIAL -> 2, etc.), then we can use simple integer comparison. To do this, we could use the ternary conditional operator (multiple times) to compute the corresponding integer variables:
Now the PDP can return Permit if Side note: currently with XACML 3.0, one way to do something similar consists to put the classification (resp. clearance) in XML form in the resource's (resp. subject's) Attributes/Content, and use an XPath 2.0 expression such as the following: If XACML supports XPath 3.0 in the future, the expression could be rewritten like this: However, the main drawback of this XPath workaround is that it requires XPath support which is not mandatory in XACML, and it works only for XML stuff in elements, not for named attributes, whereas the ternary conditional operator would work for named attributes. |
Another simpler use case is to be able to assign a default value in a VariableDefinition if it is based on some input that may be null/undefined. For example, we want to set the value of a variable In other words, let's s say we have a The resulting bag is expected to have a single string value or to be empty if the attribute is missing/undefined or has no value. It would be more convenient to have a corresponding variable as a string, so we can use the ternary conditional operator to set a
|
The proposed feature is a new XACML function that implements a ternary conditional operator such as is available in many programming languages, for example, with the syntax (a ? b : c).
In XACML terms the function would take three arguments. The first argument must evaluate to a primitive boolean value. If that value is true then the result of the function is the result of evaluating the second argument. If the value is false then the result of the function is the result of evaluating the third argument. The second and third arguments must evaluate to the same primitive type, or both to a bag of the same primitive type.
Potential URIs include:
urn:oasis:names:tc:xacml:3.0:function:conditional
urn:oasis:names:tc:xacml:3.0:function:ternary-if
The text was updated successfully, but these errors were encountered: