Authorization Using The Cedarling#
This quick start guide shows how to quickly test authorization of a user action using the Cedarling. To do this, we need 3 things.
- Authorization policy
- A request for user action
- A running instance of the Cedarling
For 1 above, we will be using Agama Lab policy designer to quickly author
a Cedar policy and a policy store.
For 2 and 3, we will use Janssen Tarp. Janssen Tarp is an easy to install browser
plug-in that comes with embedded Cedarling instance (WASM). Janssen Tarp also provides
user interface to build authorization and authentication requests for testing
purpose.
Setup#
- Install the Janssen Tarp on Chrome browser
Step-1: Create Cedar Policy and Schema#
The Cedarling needs policies and a schema to authorize access. These are bundled in a policy store (a JSON file). To create one, use Agama Lab policy designer guide and steps below. As an end result, the policy designer will publish your policy store to a GitHub repository.
Follow this video walkthrough:
https://streamable.com/kvjcv6
Schema setup#
- Open the Agama Lab policy designer and open the policy store
- Click on
Schematab- Scroll down to
Entity Typesand click on the+sign - Entity type name:
SecretDocument - Click Save
- Scroll down to
Actionsand click on it - Click on
Readand select the pencil icon - Under Resources, add
SecretDocument - Click Save
- Scroll back up and click the green
Savebutton on top of the entity list
- Scroll down to
Policy setup#
In this guide, we will use a policy that grants access only to the user
entities with the SupremeRuler role:
@id("allow_supreme_ruler")
permit(
principal is Jans::User,
action,
resource
)
when {
principal has role &&
principal.role.contains("SupremeRuler")
};
- Click on
Policiestab in policy designer - Click
Add Policyand then selectText Editor - Paste in the policy from above
- Click Save
At the end, use the Copy Link button to copy the generated policy store URI
for the next step.
Step-2: Configure Tarp#
In this step, we will add the policy store details in the Janssen Tarp that is installed in the browser. The Cedarling instance embedded in the Tarp will use the policy stored in this store to evaluate the authorization result.
- Open Tarp installed in the Chrome browser
- Navigate to the
Cedarlingtab and click onAdd Configurations - Paste the following configuration parameters as JSON. Make sure to update
the
<Policy Store URI>value to point to your policy store
{
"CEDARLING_APPLICATION_NAME": "My App",
"CEDARLING_POLICY_STORE_URI": "<Policy Store URI>",
"CEDARLING_LOG_TYPE": "std_out",
"CEDARLING_LOG_LEVEL": "INFO",
"CEDARLING_USER_AUTHZ": "enabled",
"CEDARLING_WORKLOAD_AUTHZ": "disabled",
"CEDARLING_PRINCIPAL_BOOLEAN_OPERATION": {
"===": [{"var": "Jans::User"}, "ALLOW"]
},
"CEDARLING_JWT_SIG_VALIDATION": "disabled",
"CEDARLING_JWT_STATUS_VALIDATION": "disabled",
"CEDARLING_MAPPING_USER": "Jans::User",
"CEDARLING_MAPPING_WORKLOAD": "Jans::Workload",
"CEDARLING_JWT_SIGNATURE_ALGORITHMS_SUPPORTED": [
"HS256", "RS256"
],
"CEDARLING_ID_TOKEN_TRUST_MODE": "none",
"CEDARLING_LOCK": "disabled",
"CEDARLING_LOCK_DYNAMIC_CONFIGURATION": "disabled",
"CEDARLING_LOCK_LISTEN_SSE": "disabled"
}
Click Save to initialize Cedarling. This will start the Cedarling in Tarp,
fetch and validate your policy store, and configure Cedarling to validate requests based on the User.
Step-3: Test the policy using cedarling#
Video walkthrough:
https://streamable.com/25wcb7
- Go to Tarp, under
Cedarlingtab, click onCedarling Unsigned Authz Form - Input the following:
[
{
"type": "Jans::User",
"id": "some_id",
"sub": "some_sub",
"role": ["SupremeRuler"]
}
]
Jans::Action::"Read"
{
"entity_type": "resource",
"type": "Jans::SecretDocument",
"id": "some_id"
}
The request is ready to be sent. To send the request to the Cedarling,
click on Cedarling Authz Request
{
"decision": true,
"request_id": "019602e5-b148-7d0b-9d15-9d000c0d370b",
...
}
The top-level decision: true confirms successful authorization.
Let's check a scenario where authorization is denied.
[
{
"type": "Jans::User",
"id": "some_id",
"sub": "some_sub",
"role": [""]
}
]
Cedarling Authz Request again. Cedarling will return a new result:
{
"decision": false,
...
}
The top-level decision: false shows Cedarling denying authorization.
Created: 2025-04-09