Skip to main content

Requests

Requests represent what the application sends to the OPA-based Entitlements service when asking for an Entitlement decision. DAS Entitlements dictates that the request provides a subject, action, and resource.

The DAS input structure is supports various request types. By default, the Styra DAS Entitlements system supports the following three basic input fields:

{
"action": "GET",
"resource": "/v1/systems/prod-cluster",
"subject": "alice@styra.com"
}
  1. action: Specifies the type of access being performed. For example, this may be an HTTP verb like GET or a higher-level action like read. Actions can be defined within data sources so that they can be application specific.

  2. resource: Specifies the identifying of the object being accessed. This can be an HTTP path like /v1/systems/prod-cluster or a higher-level resource like System.Configuration.

  3. subject: Specifies the id of the user or service account performing the request.

DAS Entitlements provides pre-built Rego rules (often referred to as Snippets) that leverage the known schema for the input document. Different rules rely on different parts of the input document. See the Policy Snippets page for details on which parts of the input you need to provide.

You can add your own input fields; however, the pre-built policy snippets will not understand them, and you will need to write custom Rego to take advantage of the additional inputs.

Transform a Request

In case, the input format described above does not match what your applications are sending as part of an entitlement request, you can transform the input by writing custom Rego by performing the following tasks:

  1. Create a Rego file in the folder transform/newinput.

    tip

    An example transform is provided in the default transform folder.

  2. Define a variable called newinput that captures the information provided by the application, but represents it in the input structure described above. For example, if your input provided a user field instead of the subject field described above, you can write the following Rego to transform it.

    package transform.newinput

    newinput["subject"] = input["user"]
    newinput[x] = input[x] {
    x != "user"
    }
  3. Click on the Preview button to check if your transform is working properly and supplying the actual input that your application is providing.

note

If you perform any type of additional processing within this transformation then you will not notice the transformation within the resultant authorization decision. This behavior is caused because the transformed input document is not stored in the final decision, but only the original requesting input document is retained.