Search code examples
authorizationabacalfa

Constants (constant variables) in ALFA


The OASIS Working Draft 01 for ALFA (alfa-for-xacml-v1.0-wd01) of 10 March 2015 says about constant values

3.15 Constant Values

Constant values can appear in the policy expressions. ALFA supports constants of type strings, integers, doubles and Booleans directly. Strings are quoted with single or double quotes. Integers consist of a number and optionally a minus sign. Double consists of a number with a decimal dot and optionally a minus sign. Booleans consist of the value true and false, without quotes. Other datatypes are represented using a string followed by a colon and the name of the datatype..

What that means is, you can use constant values like in that example (while report is the constant value):

target clause requestedType == "report"

But the thing is, once the ALFA files grow and you have written the constant value report all over, you might want to change the constant value into let's say my.company.attributes.medicalReport. In order to do that you have to find and replace all occurrences of the constant value.

Therefore (for the sake of avoiding redundancy) constants have been invented in other languages, where you define smth. like

const string REPORT_TYPE = "my.company.attributes.medicalReport"

or even more performant:

const integer REPORT_TYPE_ID = 3

or even more elegant:

const enum SUBJECT_TYPES { PATIENT, USER, EXAM, REPORT }

With those constants being defined I could write my target like:

target clause requestedType == REPORT_TYPE_ID

Does ALFA support constants or is there a way to "emulate" them (maybe a function that returns the desired value)?


Solution

  • Not yet! It is definitely a feature we want to have. We've had similar requests so stay tuned.