Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
d02d8b0
feat(jans-cedarling): policy store implement core data models and err…
haileyesus2433 Oct 8, 2025
9002539
feat(jans-cedarling): add policy store loader module for loading poli…
haileyesus2433 Oct 16, 2025
2ee97fb
feat(jans-cedarling): Implement Metadata Parsing and Validation (#12350)
haileyesus2433 Oct 16, 2025
e8db783
feat(jans-cedarling): add policy parser module for Cedar policy and t…
haileyesus2433 Oct 22, 2025
527dc65
feat(jans-cedarling): Implement Schema Loading and Validation (#12432)
haileyesus2433 Oct 27, 2025
29b25ac
feat(jans-cedarling): Implement Entity Loading and Validation System …
haileyesus2433 Oct 29, 2025
9972462
feat(jans-cedarling): add issuer parser module for trusted issuer con…
haileyesus2433 Nov 1, 2025
99b5ce2
feat(jans-cedarling): add TrustedIssuerValidator for JWT validation a…
haileyesus2433 Nov 4, 2025
b49806d
Merge commit '1a9cd23f296f147ec0a7aa6753077d88e621efbb' into jans-ced…
olehbozhok Nov 14, 2025
c773681
feat(jans-cedarling): Implement .cjar Archive Support and Extraction …
haileyesus2433 Nov 21, 2025
cc3defe
feat(jans-cedarling): Implement Manifest-Based Integrity Validation (…
haileyesus2433 Nov 26, 2025
656b0de
Merge branch 'main' into jans-cedarling-12253
haileyesus2433 Nov 28, 2025
58f29d4
Merge branch 'main' into jans-cedarling-12253
haileyesus2433 Dec 15, 2025
b6a1ff4
refactor(policy_store): remove default entity limits and validation l…
haileyesus2433 Dec 15, 2025
222da01
feat(jans-cedarling): Integrate Policy Store Loading with Existing Ce…
haileyesus2433 Dec 22, 2025
341f736
feat(tests): Add integration tests for policy store loader (#12884)
haileyesus2433 Dec 25, 2025
19d33b4
feat (jans-cedarling): add documentation to support new Policy Store …
haileyesus2433 Dec 31, 2025
ad8bbde
Merge branch 'main' into jans-cedarling-12253
haileyesus2433 Jan 1, 2026
4d751c3
refactor(logging): update LogEntry creation to use new system_opt_req…
haileyesus2433 Jan 1, 2026
f9945f8
Merge branch 'main' into jans-cedarling-12253
haileyesus2433 Jan 1, 2026
b4521b8
fix(jans-cedarling): wasm tests by adding conditional compilation for…
haileyesus2433 Jan 1, 2026
4957405
fix(jans-cedarling): add conditional compilation for manifest validat…
haileyesus2433 Jan 1, 2026
9a79955
refactor(policy_store): update VFS trait and error handling for WASM …
haileyesus2433 Jan 1, 2026
f13d650
fix(policy_store): add no-op check for is_file method to prevent dead…
haileyesus2433 Jan 1, 2026
21ca3b8
refactor(docs): update README files for Cedarling Go and Python bindi…
haileyesus2433 Jan 1, 2026
ce9d76b
feat(policy_store): add error handling for missing cjar_url and refac…
haileyesus2433 Jan 1, 2026
c3844ca
refactor(policy_store): improve error handling and logging documentation
haileyesus2433 Jan 1, 2026
5d901e6
refactor(policy_store): enhance error handling in VFS methods and imp…
haileyesus2433 Jan 1, 2026
e6710f2
refactor(policy_store): enhance issuer parser comments and improve lo…
haileyesus2433 Jan 1, 2026
06d8cb6
refactor(policy_store): enhance error handling and improve path checking
haileyesus2433 Jan 1, 2026
7027984
refactor(policy_store): improve benchmark performance and enhance err…
haileyesus2433 Jan 1, 2026
96b86dc
refactor(policy_store): update policy store schema for clarity and st…
haileyesus2433 Jan 1, 2026
147fa75
Merge branch 'main' into jans-cedarling-12253
haileyesus2433 Jan 1, 2026
ae74352
refactor(policy_store): enhance schema handling and improve error man…
haileyesus2433 Jan 2, 2026
8ad644e
refactor(schema): streamline validator schema handling and remove unn…
haileyesus2433 Jan 2, 2026
7b28663
refactor(benchmarks): adjust policy count for improved performance me…
haileyesus2433 Jan 2, 2026
4b0c716
revert(schema): policy store schema
haileyesus2433 Jan 2, 2026
ed8d0cc
docs(policy-store): add detailed sections for template, entity, and t…
haileyesus2433 Jan 2, 2026
c19e47c
chore(jans-cedarling): update zip crate to the latest version
haileyesus2433 Jan 5, 2026
24bcb71
fix(policy_store): ensure case-insensitive file extension validation
haileyesus2433 Jan 5, 2026
b7c6e3a
chore(jans-cedarling): remove unused JwtConfigRaw struct
haileyesus2433 Jan 5, 2026
ee6ce55
refactor(http): Updated `HttpClient` to utilize `Sender` and `Backof…
haileyesus2433 Jan 5, 2026
2282bed
refactor(policy_store): Updated `EntityParser::detect_duplicates` to …
haileyesus2433 Jan 5, 2026
c19fd04
refactor(schema): replace `SchemaParser` with `ParsedSchema` for sche…
haileyesus2433 Jan 5, 2026
82ee779
refactor(jwt): update `TrustedIssuerValidation` to use `TrustedIssuer…
haileyesus2433 Jan 5, 2026
a90e547
chore(jans-cedarling): fix indentation in `policy_store_schema.json`
haileyesus2433 Jan 5, 2026
3516e52
docs(cedarling_wasm): Updated the `init_from_archive_bytes` documenta…
haileyesus2433 Jan 5, 2026
4d6b214
docs(cedarling): improve formatting and clarity in Go tutorial and RE…
haileyesus2433 Jan 5, 2026
d97070c
refactor(policy_store): enhance path normalization in `normalize_path…
haileyesus2433 Jan 5, 2026
851df01
refactor(policy_store): simplify error handling in `load_policy_store…
haileyesus2433 Jan 5, 2026
fef81c2
docs(cedarling): enhance example configurations in README for policy …
haileyesus2433 Jan 5, 2026
1b40668
test(policy_store): add precondition assertions for checksum mismatch…
haileyesus2433 Jan 5, 2026
7788ea3
refactor(policy_store): remove unused WASM stub for loading policy st…
haileyesus2433 Jan 5, 2026
bda40f6
refactor(policy_store): add WASM stub for loading policy store archiv…
haileyesus2433 Jan 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
243 changes: 239 additions & 4 deletions docs/cedarling/reference/cedarling-policy-store.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,242 @@ For a comprehensive JSON schema defining the structure of the policy store, see:

**Note:** The `cedarling_store.json` file is only needed if the bootstrap properties: `CEDARLING_LOCK`; `CEDARLING_POLICY_STORE_URI`; and `CEDARLING_POLICY_STORE_ID` are not set to a local location. If you're fetching the policies remotely, you don't need a `cedarling_store.json` file.

## JSON Schema
## Policy Store Formats

Cedarling supports two policy store formats and automatically detects the correct format based on file extension or URL:

| Configuration | Detection |
|---------------|-----------|
| `CEDARLING_POLICY_STORE_URI` ending in `.cjar` | Cedar Archive from URL |
| `CEDARLING_POLICY_STORE_URI` (other) | Legacy JSON from Lock Server |
| `CEDARLING_POLICY_STORE_LOCAL_FN` pointing to directory | Directory-based format |
| `CEDARLING_POLICY_STORE_LOCAL_FN` with `.cjar` extension | Cedar Archive file |
| `CEDARLING_POLICY_STORE_LOCAL_FN` with `.json` extension | JSON file |
| `CEDARLING_POLICY_STORE_LOCAL_FN` with `.yaml`/`.yml` extension | YAML file |

### 1. Legacy Single-File Format (JSON/YAML)

The original format stores all policies and schema in a single JSON or YAML file with Base64-encoded content. This is documented in detail in the sections below.

### 2. New Directory-Based Format

The new directory-based format uses human-readable Cedar files organized in a structured directory:

```text
policy-store/
├── metadata.json # Required: Store identification and versioning
├── manifest.json # Optional: File checksums for integrity validation
├── schema.cedarschema # Required: Cedar schema in human-readable format
├── policies/ # Required: Directory containing .cedar policy files
│ ├── allow-read.cedar
│ └── deny-guest.cedar
├── templates/ # Optional: Directory containing .cedar template files
├── entities/ # Optional: Directory containing .json entity files
└── trusted-issuers/ # Optional: Directory containing .json issuer configs
```

#### metadata.json

Contains policy store identification and versioning:

```json
{
"cedar_version": "4.4.0",
"policy_store": {
"id": "abc123def456",
"name": "My Application Policies",
"description": "Optional description",
"version": "1.0.0",
"created_date": "2024-01-01T00:00:00Z",
"updated_date": "2024-01-02T00:00:00Z"
}
}
```

#### manifest.json (Optional)

Provides integrity validation with file checksums:

```json
{
"policy_store_id": "abc123def456",
"generated_date": "2024-01-01T12:00:00Z",
"files": {
"metadata.json": {
"size": 245,
"checksum": "sha256:abc123..."
},
"schema.cedarschema": {
"size": 1024,
"checksum": "sha256:def456..."
}
}
}
```

When a manifest is present, Cedarling validates:

- File checksums match (SHA-256)
- File sizes match
- Policy store ID matches between manifest and metadata

#### Policy Files

Policies are stored as human-readable `.cedar` files in the `policies/` directory:

```cedar
@id("allow-read")
permit(
principal,
action == MyApp::Action::"read",
resource
);
```

Each policy file must have an `@id` annotation that uniquely identifies the policy.

#### Template Files

Templates are stored as human-readable `.cedar` files in the `templates/` directory:

```cedar
@id("resource-access-template")
permit(
principal == ?principal,
action,
resource == ?resource
);
```

Each template file must have an `@id` annotation and use Cedar's template slot syntax (`?principal`, `?resource`).

#### Entity Files

Entity files in the `entities/` directory use the Cedar JSON entity format as a **JSON array**. Each file can contain one or more entity definitions:

```json
[
{
"uid": {
"type": "Jans::Organization",
"id": "acme-dolphins"
},
"attrs": {
"name": "Acme Dolphins Division",
"org_id": "100129",
"domain": "acme-dolphin.sea",
"regions": ["Atlantic", "Pacific", "Indian"]
},
"parents": []
},
{
"uid": {
"type": "Jans::Role",
"id": "admin"
},
"attrs": {
"name": "Administrator",
"permissions": ["read", "write", "delete"]
},
"parents": []
}
]
```

Each entity requires:

- **`uid`**: Object with `type` (Cedar entity type name, e.g., `"Jans::Organization"`) and `id` (unique entity identifier)
- **`attrs`**: Object containing entity attributes matching your Cedar schema
- **`parents`**: Optional array of parent entity references for hierarchical relationships

Example with parent relationships (`entities/users.json`):

```json
[
{
"uid": {
"type": "Jans::User",
"id": "alice"
},
"attrs": {
"name": "Alice Smith",
"email": "alice@example.com"
},
"parents": [
{"type": "Jans::Role", "id": "admin"},
{"type": "Jans::Organization", "id": "acme-dolphins"}
]
}
]
```

#### Trusted Issuer Files

Trusted issuer configuration files in the `trusted-issuers/` directory define identity providers that can issue tokens. Each file contains a JSON object mapping issuer IDs to their configurations:

```json
{
"jans_issuer": {
"name": "Jans Server",
"description": "Primary Janssen Identity Provider",
"openid_configuration_endpoint": "https://jans.example.com/.well-known/openid-configuration",
"token_metadata": {
"access_token": {
"trusted": true,
"entity_type_name": "Jans::Access_token",
"token_id": "jti",
"workload_id": "aud"
},
"id_token": {
"trusted": true,
"entity_type_name": "Jans::Id_token",
"user_id": "sub",
"role_mapping": "role"
}
}
}
}
```

Each trusted issuer configuration includes:

- **`name`**: Human-readable name for the issuer (used as namespace for `TrustedIssuer` entity)
- **`description`**: Optional description of the issuer
- **`openid_configuration_endpoint`**: HTTPS URL for the OpenID Connect discovery endpoint
- **`token_metadata`**: Map of token types to their metadata configuration (see [Token Metadata Schema](#token-metadata-schema))

You can define multiple issuers in a single file or split them across multiple files in the `trusted-issuers/` directory.

#### Cedar Archive (.cjar) Format

The directory structure can be packaged as a `.cjar` file (ZIP archive) for distribution:

```bash
# Create a .cjar archive from a policy store directory
cd policy-store && zip -r ../policy-store.cjar .
```

**Note:** In WASM environments, only URL-based and inline string sources are available. Use `CEDARLING_POLICY_STORE_URI` with a `.cjar` URL or `init_from_archive_bytes()` for custom fetch scenarios.

## Advanced: Loading from Bytes

For scenarios requiring custom fetch logic (e.g., auth headers), archive bytes can be loaded directly:

- **WASM**: Use `init_from_archive_bytes(config, bytes)` function
- **Rust**: Use `PolicyStoreSource::ArchiveBytes(Vec<u8>)` or `load_policy_store_archive_bytes()` function

```javascript
// WASM example with custom fetch
const response = await fetch(url, { headers: { Authorization: "..." } });
const bytes = new Uint8Array(await response.arrayBuffer());
const cedarling = await init_from_archive_bytes(config, bytes);
```

## Legacy Single-File Format (JSON)

The following sections document the legacy single-file JSON format.

### JSON Schema

The JSON Schema accepted by Cedarling is defined as follows:

Expand Down Expand Up @@ -510,9 +745,9 @@ entity Tokens = {

The naming follows this pattern:

- **Issuer name**: From trusted issuer metadata `name` field, or hostname from JWT `iss` claim
- **Token type**: Extracted from the `mapping` field (e.g., "Jans::Access_Token" → "access_token")
- Both converted to lowercase with underscores replacing special characters
- **Issuer name**: From trusted issuer metadata `name` field, or hostname from JWT `iss` claim
- **Token type**: Extracted from the `mapping` field (e.g., "Jans::Access_Token" → "access_token")
- Both converted to lowercase with underscores replacing special characters

### Schema Requirements for Multi-Issuer

Expand Down
18 changes: 15 additions & 3 deletions docs/cedarling/reference/cedarling-properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,24 @@ To load policy store one of the following keys must be provided:

- **`CEDARLING_POLICY_STORE_LOCAL`** : JSON object as string with policy store. You can use [this](https://jsontostring.com/) converter.

- **`CEDARLING_POLICY_STORE_URI`** : Location of policy store JSON, used if policy store is not local, or retrieved from Lock Master.
- **`CEDARLING_POLICY_STORE_URI`** : URL to fetch policy store from. Cedarling automatically detects the format:
- URLs ending in `.cjar` → loads as Cedar Archive
- Other URLs → loads as legacy JSON from Lock Server

- **`CEDARLING_POLICY_STORE_LOCAL_FN`** : Path to a Policy Store JSON file
- **`CEDARLING_POLICY_STORE_LOCAL_FN`** : Path to local policy store. Cedarling automatically detects the format:
- Directories → loads as directory-based policy store
- `.cjar` files → loads as Cedar Archive
- `.json` files → loads as JSON
- `.yaml`/`.yml` files → loads as YAML

**New Directory-Based Format** (Native platforms only):

Cedarling now supports a directory-based policy store format with human-readable Cedar files. See [Policy Store Formats](./cedarling-policy-store.md#policy-store-formats) for details.

**Note:** In WASM environments, only `CEDARLING_POLICY_STORE_URI` and `CEDARLING_POLICY_STORE_LOCAL` are available. File and directory sources (`CEDARLING_POLICY_STORE_LOCAL_FN`) are not supported in WASM due to lack of filesystem access.

!!! NOTE
All other fields are optional and can be omitted. If a field is not provided, Cedarling will use the default value specified in the property definition.
All other fields are optional and can be omitted. If a field is not provided, Cedarling will use the default value specified in the property definition.

**Auxilliary properties**

Expand Down
48 changes: 39 additions & 9 deletions docs/cedarling/tutorials/go.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Go bindings for the Jans Cedarling authorization engine, providing policy-based

### Build with dynamic linking

1. Download the appropriate pre-built binary for your platform from the Jans releases page or build it from source as
described above.
1. Download the appropriate pre-built binary for your platform from the Jans releases page or build it from source as
described above.

2. Specify linker flags in your main.go file to link against the Cedarling library.

Expand Down Expand Up @@ -42,14 +42,14 @@ described above.
- **Windows**

- Place the Rust artifacts (`cedarling_go.dll` and `cedarling_go.lib`) alongside the Go binary.
- Windows searches libraries in directories below in the
- Windows searches libraries in directories below in the
following order
1. The directory containing your Go executable (recommended location)
2. Windows system directories (e.g., `C:\Windows\System32`)
3. The `PATH` environment variable directories

- **Linux**

Add the library directory that contains `libcedarling_go.so` to the
`LD_LIBRARY_PATH` environment variable

Expand All @@ -58,10 +58,10 @@ described above.
```

- **MacOS**

Add the library directory that contains `libcedarling_go.dylib` to the
`LD_LIBRARY_PATH` environment variable

```sh
export DYLD_LIBRARY_PATH=$(pwd):$DYLD_LIBRARY_PATH
```
Expand Down Expand Up @@ -147,14 +147,44 @@ if err != nil {
}
```

### Policy Store Sources

Go bindings support all native policy store source types. See [Cedarling Properties](../reference/cedarling-properties.md) for the full list of configuration options.

**Example configurations:**

```go
// Load from a directory
config := map[string]any{
"CEDARLING_APPLICATION_NAME": "MyApp",
"CEDARLING_POLICY_STORE_LOCAL_FN": "/path/to/policy-store/",
// ... other config
}

// Load from a local .cjar archive (Cedar Archive)
config := map[string]any{
"CEDARLING_APPLICATION_NAME": "MyApp",
"CEDARLING_POLICY_STORE_LOCAL_FN": "/path/to/policy-store.cjar",
// ... other config
}

// Load from a remote .cjar archive (Cedar Archive)
config := map[string]any{
"CEDARLING_APPLICATION_NAME": "MyApp",
"CEDARLING_POLICY_STORE_URI": "https://example.com/policy-store.cjar",
// ... other config
}
```

See [Policy Store Formats](../reference/cedarling-policy-store.md#policy-store-formats) for more details.

### Authorization

Cedarling provides two main interfaces for performing authorization checks: **Token-Based Authorization** and **Unsigned Authorization**. Both methods involve evaluating access requests based on various factors, including principals (entities), actions, resources, and context. The difference lies in how the Principals are provided.

- [**Token-Based Authorization**](#token-based-authorization) is the standard method where principals are extracted from JSON Web Tokens (JWTs), typically used in scenarios where you have existing user authentication and authorization data encapsulated in tokens.
- [**Unsigned Authorization**](#unsigned-authorization) allows you to pass principals directly, bypassing tokens entirely. This is useful when you need to authorize based on internal application data, or when tokens are not available.


#### Token-Based Authorization

**1. Define the resource:**
Expand Down Expand Up @@ -318,10 +348,10 @@ if err != nil {
if result.Decision {
fmt.Println("Access granted")
fmt.Printf("Request ID: %s\n", result.RequestID)

// Access detailed Cedar response
fmt.Printf("Cedar decision: %s\n", result.Response.Decision().ToString())

// Get diagnostic information
diagnostics := result.Response.Diagnostics()
if len(diagnostics.Reason()) > 0 {
Expand Down
Loading
Loading