cedarling
cedarling
Crystal bindings for the Cedarling policy decision point, generated with uniffi-bindgen-crystal from Cedarling's UniFFI interface.
Cedarling evaluates Cedar policies locally and answers one question: should this application allow this action on this resource for this principal? It loads a policy store (Cedar schema, policies, optionally trusted issuers and default entities) at startup and then serves authorization requests with no network round-trip per decision.
- Generated, not hand-written:
src/bindings/is produced from the crate's UniFFI metadata;src/cedarling.cronly re-exports constructors and common types. - Full surface: objects (
Cedarling), records (EntityData,JsonValue,AuthorizeResult, ...), enums (Decision,DropReason, ...), errors (CedarlingError,AuthorizeError,DataError,LogError, ...), unsigned and multi-issuer authorization, batch authorization, logs, the context data API and metrics. - Self-contained: the generated runtime is vendored in
src/bindings/, so the shard needs no other Crystal dependency.
Contents
- Status
- Requirements
- Building the native library
- Installing the shard
- Quick start
- Policy stores
- Writing policies
- Bootstrap configuration
- Authorization methods
- Logs
- Running Cedarling from Crystal
- Interface reference
- Regenerating the bindings
- Troubleshooting
- Vendor documentation
Status
Upstream Cedarling currently pins uniffi 0.32, while this generator targets UniFFI 0.33. These bindings are generated from a Cedarling build with uniffi/uniffi_macros bumped to 0.33; no Cedarling source changes were needed. The native library and src/bindings/ must be built together — the contract-version check rejects a mismatched library at load time.
| cedarling (shard) | uniffi-bindgen-crystal | uniFFI | Cedarling |
|---|---|---|---|
| 0.1 | 0.1 | 0.33 | main (jans-cedarling) |
Requirements
- Crystal 1.22.3 or newer
- A built
libcedarling_uniffishared library - Rust 1.95+ (the crate's toolchain),
protoc, andgitonly when building Cedarling or regenerating the bindings
Building the native library
Cedarling lives in the Janssen monorepo. A sparse checkout of jans-cedarling is enough:
git clone --depth 1 --filter=blob:none --sparse https://github.com/JanssenProject/jans.git
cd jans
git sparse-checkout set jans-cedarling
cd jans-cedarling
protoc is required (the crate builds gRPC support by default):
brew install protobuf # macOS
sudo apt-get install protobuf-compiler libgc-dev libpcre2-dev # Debian/Ubuntu
Match the UniFFI version used by these bindings (0.33):
# In jans-cedarling/Cargo.toml:
# uniffi = "0.32.1" -> uniffi = "0.33.0"
# uniffi_macros = "0.32.1" -> uniffi_macros = "0.33.0"
cargo build -p cedarling_uniffi --release
The library is target/release/libcedarling_uniffi.dylib (macOS) or .so (Linux). scripts/generate.sh performs the version bump, build and binding regeneration for you.
Installing the shard
dependencies:
cedarling:
github: dsisnero/cedarling
shards install
Because the bindings are generated for a specific native library, the shard does not compile the Rust library. Point the loader at it before running:
export LD_LIBRARY_PATH=/path/to/jans-cedarling/target/release # Linux
export DYLD_LIBRARY_PATH=/path/to/jans-cedarling/target/release # macOS
Quick start
A complete, runnable example lives in examples/basic/: a directory policy store, a bootstrap config and a Crystal program that prints one allow and one deny.
CEDARLING_LIB_DIR=/path/to/target/release scripts/example.sh
The script sets CRYSTAL_LIBRARY_PATH and the loader path for you; running directly with crystal run examples/basic/run.cr works too once those are set.
require "cedarling"
require "json"
config = JSON.parse(File.read("bootstrap.json")).as_h
config["CEDARLING_POLICY_STORE_LOCAL_FN"] = JSON::Any.new("/abs/path/policy-store")
cedarling = Cedarling.load_from_json(config.to_json)
principal = Cedarling::EntityData.from_json(%({
"cedar_entity_mapping": { "entity_type": "Jans::TestPrincipal", "id": "alice" },
"sub": "alice",
"is_ok": true
}))
resource = Cedarling::EntityData.from_json(%({
"cedar_entity_mapping": { "entity_type": "Jans::Issue", "id": "ticket-10101" },
"sub": "alice",
"app_id": "admin_ui",
"name": "Printer on fire",
"permission": "view_clients"
}))
result = cedarling.authorize_unsigned(
principal,
%(Jans::Action::"UpdateTestPrincipal"),
resource,
Cedarling::JsonValue.new("{}"),
)
puts result.decision # => true
cedarling.close
EntityData is the Cedarling entity format: cedar_entity_mapping selects the Cedar entity type and id, every other field becomes an entity attribute. The attributes must match the policy store's schema (strict validation is on by default).
Policy stores
Cedarling loads one of:
| Source | Property | Format |
|---|---|---|
| Local path | CEDARLING_POLICY_STORE_LOCAL_FN |
Directory, .cjar archive, or .yaml/.yml (test suites) |
| Remote URL | CEDARLING_POLICY_STORE_URI |
.cjar or ZIP archive |
| Inline string | CEDARLING_POLICY_STORE_LOCAL |
Inline YAML (test suites) |
Directory format (recommended)
policy-store/
├── metadata.json # required: spec version, Cedar version, store id
├── schema.cedarschema # required in strict mode (or schemas/*.cedarschema)
├── policies/ # required: one or more *.cedar files
│ ├── allow-update.cedar
│ └── deny-other.cedar
├── templates/ # optional: Cedar policy templates
├── entities/ # optional: default entities (JSON arrays)
└── trusted-issuers.json # optional: accepted token types (multi-issuer)
metadata.json:
{
"policy_store_spec_version": 2,
"cedar_version": "4.4.0",
"policy_store": {
"id": "7f3a9c21d4e8b560",
"name": "My Application Policies",
"version": "1.0.0"
}
}
policy_store_spec_versionis the store layout version (currently 2).policy_store.idmust be 8-64 hex characters.- Each file with more than one policy needs
@id("...")on every policy; a single-policy file may omit it and the file name becomes the policy id.
Package a directory as a Cedar Archive for distribution:
cd policy-store && zip -r ../policy-store.cjar .
YAML format (test suites only)
The single-file YAML store used by the upstream fixtures (and by this shard's spec/fixtures/policy-store.yaml) is supported only for test suites:
cedar_version: v4.0.0
policy_stores:
a1bf93115de86de760ee0bea1d529b521489e5a11747:
name: Test store
schema: <base64 or {encoding, content_type, body}>
policies:
allow-read:
description: allow reads
policy_content:
encoding: none
content_type: cedar
body: "permit(principal, action == Jans::Action::\"Read\", resource);"
trusted_issuers: { ... }
Use the directory format in production.
Default entities
Static entities in entities/*.json (or default_entities in YAML) are loaded at startup and available to every request. When a request entity has the same UID as a default entity, the default entity wins, so policy-store data cannot be overwritten by caller-supplied data.
Writing policies
Cedar policies are text files with a scope (principal, action, resource) and optional when/unless conditions. Every policy must end with ;. Evaluation combines all matching policies:
- at least one
permitand zeroforbid→Allow; - any
forbid→Deny(explicit deny always wins); - no matching
permit→Deny(implicit deny).
1. Define the schema
The schema is what lets Cedarling validate requests and policies. A minimal schema for the example:
namespace Jans {
entity TestPrincipal = {
sub: String,
is_ok: Bool
};
entity Issue = {
sub: String,
app_id: String,
name: String,
permission: String
};
action "UpdateTestPrincipal" appliesTo {
principal: [TestPrincipal],
resource: [Issue]
};
}
Attribute names must match the JSON sent in EntityData. Actions are grouped in action ... appliesTo { principal: [...], resource: [...], context: {...} }. In token-based deployments the schema also declares token entities (Jans::Access_token, Jans::Id_token, ...) and context: { access_token: ... } for actions that use them.
2. Write the policies
// Permit a principal to update an issue it owns.
@id("allow-update-own-issue")
permit(
principal is Jans::TestPrincipal,
action == Jans::Action::"UpdateTestPrincipal",
resource is Jans::Issue
)
when {
principal.sub == resource.sub
};
// Explicit deny for everything else: it always overrides a permit.
@id("deny-update-other-issue")
forbid(
principal is Jans::TestPrincipal,
action == Jans::Action::"UpdateTestPrincipal",
resource is Jans::Issue
)
when {
principal.sub != resource.sub
};
Scope and condition syntax:
principal // any principal
principal == User::"alice" // one entity
principal is User // any entity of that type
principal in Group::"admins" // membership in a hierarchy
action in [Action::"read", Action::"write"]
resource is Document
when { resource.owner == principal.sub }
unless { principal.suspended }
when { context.time < 1719266610 }
when { context has tokens.acme_access_token &&
context.tokens.acme_access_token.hasTag("scope") &&
context.tokens.acme_access_token.getTag("scope").contains("read:documents") }
Annotations (@id, @advice, ...) are arbitrary metadata; Cedarling reports policy ids from the decision diagnostics and exposes the annotations through the policy APIs.
3. Validate the store
The vendor ships cedarling-cli validate, which checks the schema, policies, trusted issuers and store layout before you deploy:
cd jans-cedarling
cargo run -p cedarling-cli -- validate --policy-store /path/to/policy-store
Run it with --strict in CI: unknown keys (for example a misspelled required_claims) are otherwise ignored.
Token-based (multi-issuer) policies
authorize_multi_issuer validates JWTs instead of taking a principal. Each accepted token becomes a Cedar entity in the request context under the key {issuer}_{token_type}, where the issuer is the trusted-issuers.json entry's name, lowercased, and the type is the last segment of the TokenInput mapping, lowercased (Jans::Access_token -> jans_access_token):
@id("allow-read-with-scope")
permit(
principal,
action == Jans::Action::"Read",
resource is Jans::Document
)
when {
context has tokens.jans_access_token &&
context.tokens.jans_access_token.hasTag("scope") &&
context.tokens.jans_access_token.getTag("scope").contains("read:documents")
};
Tokens are optional: invalid or duplicate tokens are dropped (see result.dropped_tokens), so a policy that depends on a token should fail closed:
forbid(principal, action, resource) unless { context has tokens.jans_access_token };
The schema must declare the token entity types and the action's context.tokens record; the exact shape is in the vendor multi-issuer schema requirements and trusted-issuers.json reference. Accepted token types are configured in trusted-issuers.json, not in the bootstrap config.
Bootstrap configuration
Cedarling is configured with a JSON object passed to Cedarling.load_from_json or a JSON file passed to Cedarling.load_from_file. The most useful keys:
| Property | Values / default | Purpose |
|---|---|---|
CEDARLING_APPLICATION_NAME |
required | Human-friendly instance name |
CEDARLING_POLICY_STORE_LOCAL_FN |
path | Load a local directory/.cjar/YAML store |
CEDARLING_POLICY_STORE_URI |
URL | Fetch a .cjar store over HTTPS |
CEDARLING_LOG_TYPE |
off (default), memory, std_out |
Where decision/system logs go |
CEDARLING_LOG_LEVEL |
WARN (default) |
Minimum level for system logs |
CEDARLING_LOG_TTL |
seconds, required for memory |
Log retention |
CEDARLING_JWT_SIG_VALIDATION |
enabled (default) |
Verify JWT signatures |
CEDARLING_JWT_STATUS_VALIDATION |
enabled (default) |
Check token status lists |
CEDARLING_JWT_SIGNATURE_ALGORITHMS_SUPPORTED |
e.g. ["RS256", "ES256"] |
Accepted algorithms |
CEDARLING_LOCAL_JWKS |
path | Local JWKS for development/air-gapped use |
CEDARLING_STRICT_SCHEMA_VALIDATION |
enabled (default) |
Require and enforce a schema |
CEDARLING_POLICY_STORE_REFRESH_INTERVAL |
seconds, default 0 |
Background refresh for URL stores |
CEDARLING_DATA_STORE_MAX_ENTRIES |
default 10000 |
Context data API entries |
CEDARLING_TRACE |
disabled (default) |
Emit signed TRACE records to Lock Server |
CEDARLING_LOCK |
disabled (default) |
Lock Server integration |
CEDARLING_METRICS_COLLECTION |
disabled (default) |
Local metrics for drain_metrics |
Full descriptions and defaults are in the vendor Properties reference.
Example:
{
"CEDARLING_APPLICATION_NAME": "my-service",
"CEDARLING_POLICY_STORE_LOCAL_FN": "/etc/cedarling/policy-store",
"CEDARLING_LOG_TYPE": "memory",
"CEDARLING_LOG_TTL": 300,
"CEDARLING_LOG_LEVEL": "INFO",
"CEDARLING_JWT_SIG_VALIDATION": "enabled",
"CEDARLING_JWT_SIGNATURE_ALGORITHMS_SUPPORTED": ["RS256", "ES256"]
}
Authorization methods
Unsigned (authorize_unsigned)
Use when the application has already authenticated the caller and wants to pass entity data directly. No token validation is performed.
result = cedarling.authorize_unsigned(
principal, # EntityData? (nil = partial evaluation)
%(Jans::Action::"UpdateTestPrincipal"),# action UID
resource, # EntityData
Cedarling::JsonValue.new("{}"), # context (JSON object)
)
result.decision # Bool
result.request_id # String, also used in the decision log
result.response # Cedar Response with diagnostics
Passing nil for the principal runs Cedar's partial evaluator. Policies that do not depend on the principal can still allow; if a residual policy could allow, Cedarling fails closed and returns Deny.
Multi-issuer (authorize_multi_issuer)
Validates JWTs from the store's trusted issuers and exposes each token to policies as context.tokens.{issuer}_{token_type}.
tokens = [
Cedarling::TokenInput.new("Jans::Access_token", access_token_jwt),
Cedarling::TokenInput.new("Jans::Id_token", id_token_jwt),
]
result = cedarling.authorize_multi_issuer(
tokens,
%(Jans::Action::"Read"),
resource,
nil, # context is optional (JsonValue?)
)
result.decision
result.dropped_tokens # tokens that failed validation, with reasons
A policy that depends on a token must require it, because failing tokens are dropped instead of failing the request:
forbid(principal, action, resource) unless { context has tokens.jans_access_token };
Batch
authorize_unsigned_batch and authorize_multi_issuer_batch evaluate many {resource, action, context} items against one entity/token snapshot:
items = [
Cedarling::BatchItem.new(resource_one, %(Jans::Action::"Read")),
Cedarling::BatchItem.new(resource_two, %(Jans::Action::"Update"), Cedarling::JsonValue.new("{}")),
]
response = cedarling.authorize_unsigned_batch(principal, items)
response.batch_id # also the request id of the per-item log entries
response.results.each do |slot|
case slot
when CedarlingUniffi::BatchItemUnsignedOutcome::Success
puts "decision=#{slot.result.decision}"
when CedarlingUniffi::BatchItemUnsignedOutcome::Failed
puts "item #{slot.error.item_index}: #{slot.error.category} (#{slot.error.message})"
end
end
Result slots preserve the input order; a per-item failure does not fail the whole batch.
Options and TRACE
Pass Cedarling::AuthorizeOptions as the last argument to attach the TRACE execution context (when TRACE is enabled):
trace = Cedarling::TraceContext.new(
execution_id: "01J9Z3K4N6Q8R0S2T4V6W8X0Y2",
execution_authority: "https://gateway.example.com",
workload_id: "billing-service",
)
cedarling.authorize_unsigned(principal, action, resource, context,
Cedarling::AuthorizeOptions.new(trace))
Logs
Set CEDARLING_LOG_TYPE to memory (with a TTL) to keep decision and system logs in process, or std_out to stream them; off discards them.
cedarling.get_log_ids # Array(String)
cedarling.get_log_by_id(id) # JSON string
cedarling.get_logs_by_tag("Decision") # by log_kind / level
cedarling.get_logs_by_request_id(result.request_id)
cedarling.get_logs_by_request_id_and_tag(result.request_id, "Decision")
cedarling.pop_logs # drain everything
Running Cedarling from Crystal
Cedarling's policy engine (cedar-policy) checks the remaining stack with stacker before evaluation. That check misreads Crystal fiber stacks, so calling any Cedarling method from a spawned fiber fails with recursion limit reached / AuthorizationFailed, while calls from the main fiber and from Threads work. Fiber-based servers (Kemal, Lucky, Athena, ...) should use the helper, which runs the block on a dedicated thread:
decision = Cedarling.on_thread do
cedarling.authorize_unsigned(principal, action, resource, context).decision
end
Close the instance when the service shuts down to release the Rust Arc and flush logs:
cedarling.close
# or, when the process owns the instance exclusively:
cedarling.shut_down
Interface reference
The complete API generated from Cedarling's UniFFI interface. Vendor docs use camelCase (loadFromJson, authorizeUnsigned); Crystal uses snake_case (load_from_json, authorize_unsigned). All methods are on the Cedarling class unless marked otherwise.
Vendor "Exposed Functions" mapping
| Vendor function | Crystal |
|---|---|
Cedarling::load_from_json |
Cedarling.load_from_json(config) |
Cedarling::load_from_file |
Cedarling.load_from_file(path) |
Cedarling::load_from_json_with_archive_bytes |
Cedarling.load_from_json_with_archive_bytes(config, bytes) |
Cedarling::authorize_unsigned |
#authorize_unsigned(...) |
Cedarling::pop_logs |
#pop_logs |
Cedarling::get_log_by_id |
#get_log_by_id(id) |
Cedarling::get_log_ids |
#get_log_ids |
Cedarling::get_logs_by_tag |
#get_logs_by_tag(tag) |
Cedarling::get_logs_by_request_id |
#get_logs_by_request_id(request_id) |
Cedarling::get_logs_by_request_id_and_tag |
#get_logs_by_request_id_and_tag(request_id, tag) |
The current crate additionally exposes multi-issuer and batch authorization, the context data API, metrics and trusted-issuer status; they are listed below.
Constructors and lifecycle
| Method | Returns | Raises |
|---|---|---|
Cedarling.load_from_json(config : String) |
Cedarling |
CedarlingError |
Cedarling.load_from_file(path : String) |
Cedarling |
CedarlingError |
Cedarling.load_from_json_with_archive_bytes(config : String, archive_bytes : Bytes) |
Cedarling |
CedarlingError |
#close : Nil |
— | — |
#closed? : Bool |
Bool |
— |
#shut_down : Nil |
— | — |
cedarling = Cedarling.load_from_json(config_json) # JSON string
cedarling = Cedarling.load_from_file("bootstrap.json") # same, from a file
bytes = File.read("policy-store.cjar").to_slice
cedarling = Cedarling.load_from_json_with_archive_bytes(config_json, bytes)
cedarling.close
load_from_json_with_archive_bytes loads a bootstrap JSON string plus the raw bytes of a Cedar archive (.cjar); the policy-store path/URL fields in the config are ignored in favour of the bytes.
Authorization
| Method | Returns | Raises |
|---|---|---|
#authorize_unsigned(principal : EntityData?, action : String, resource : EntityData, context : JsonValue, options : AuthorizeOptions? = nil) |
AuthorizeResult |
AuthorizeError |
#authorize_multi_issuer(tokens : Array(TokenInput), action : String, resource : EntityData, context : JsonValue?, options : AuthorizeOptions? = nil) |
MultiIssuerAuthorizeResult |
AuthorizeError |
#authorize_unsigned_batch(principal : EntityData?, items : Array(BatchItem), options : AuthorizeOptions? = nil) |
BatchAuthorizeUnsignedResponse |
AuthorizeError |
#authorize_multi_issuer_batch(tokens : Array(TokenInput), items : Array(BatchItem), options : AuthorizeOptions? = nil) |
BatchAuthorizeMultiIssuerResponse |
AuthorizeError |
# Unsigned: pass an asserted principal (or nil for partial evaluation).
result = cedarling.authorize_unsigned(
principal,
%(Jans::Action::"UpdateTestPrincipal"),
resource,
Cedarling::JsonValue.new("{}"),
)
result.decision # Bool
result.request_id # String
result.response # Response (decision + diagnostics)
# Multi-issuer: validated JWTs become context.tokens.{issuer}_{type}.
result = cedarling.authorize_multi_issuer(
[Cedarling::TokenInput.new("Jans::Access_token", jwt)],
%(Jans::Action::"Read"),
resource,
nil,
)
result.dropped_tokens.each { |token| puts token.reason }
# Batch: one entity/token snapshot, N {resource, action, context} items.
response = cedarling.authorize_unsigned_batch(principal, items)
response.batch_id
response.results.each do |slot|
case slot
when CedarlingUniffi::BatchItemUnsignedOutcome::Success
puts slot.result.decision
when CedarlingUniffi::BatchItemUnsignedOutcome::Failed
puts slot.error.category
end
end
Logs
| Method | Returns | Raises |
|---|---|---|
#pop_logs : Array(String) |
log entries as JSON strings; drains the store | LogError |
#get_log_ids : Array(String) |
ids of the current entries | — |
#get_log_by_id(id : String) : String |
one entry as JSON | LogError |
#get_logs_by_tag(tag : String) : Array(String) |
entries matching a tag (log_kind, level, ...) |
LogError |
#get_logs_by_request_id(request_id : String) : Array(String) |
entries for one request (or batch id) | LogError |
#get_logs_by_request_id_and_tag(request_id : String, tag : String) : Array(String) |
entries for one request and tag | LogError |
Logs are only retained with CEDARLING_LOG_TYPE=memory and a CEDARLING_LOG_TTL; std_out streams them and off discards them.
Context data API
| Method | Returns | Raises |
|---|---|---|
#push_data_ctx(key : String, value : JsonValue, ttl_secs : Int64?) : Nil |
— | DataError |
#get_data_ctx(key : String) : JsonValue? |
value or nil |
DataError |
#get_data_entry_ctx(key : String) : DataEntry? |
entry metadata and value | DataError |
#list_data_ctx : Array(DataEntry) |
all live entries | DataError |
#remove_data_ctx(key : String) : Bool |
whether an entry was removed | DataError |
#clear_data_ctx : Nil |
remove every entry | DataError |
#get_stats_ctx : DataStoreStats |
entry/size/capacity statistics | DataError |
Data pushed here is available to policies under context.data.
Metrics and trusted-issuer status
| Method | Returns | Raises |
|---|---|---|
#drain_metrics : MetricsSnapshot |
per-policy, error and operational counters; resets the interval | MetricsError |
#policy_store_id : String? |
current store id (can change after a refresh) | — |
#total_issuers : Int64 |
configured trusted issuers | — |
#loaded_trusted_issuer_ids : Array(String) |
issuers loaded successfully | — |
#failed_trusted_issuer_ids : Array(String) |
issuers that failed to load | — |
#loaded_trusted_issuers_count : Int64 |
number loaded | — |
#is_trusted_issuer_loaded_by_name(issuer_name : String) : Bool |
status by issuer name | — |
#is_trusted_issuer_loaded_by_iss(iss_claim : String) : Bool |
status by iss claim |
— |
drain_metrics requires CEDARLING_METRICS_COLLECTION=enabled and raises MetricsError::NotEnabled otherwise; MetricsError::LockTelemetry means the Lock telemetry ticker owns the collector.
Supporting types
| Type | Constructors / fields |
|---|---|
Cedarling::EntityData |
from_json(json : String), new(entity_type : String, id : String, payload : Hash(String, JsonValue)), close |
Cedarling::JsonValue |
new(value : String) — a JSON document as text |
Cedarling::TokenInput |
new(mapping : String, payload : String); getters mapping, payload |
Cedarling::BatchItem |
new(resource : EntityData, action : String, context : JsonValue? = nil) |
Cedarling::AuthorizeOptions |
new(trace : TraceContext? = nil) |
Cedarling::TraceContext |
new(execution_id, execution_authority, workload_id, workload_instance_id = nil) |
Cedarling::AuthorizeResult |
response : Response, decision : Bool, request_id : String |
Cedarling::MultiIssuerAuthorizeResult |
response, decision, request_id, dropped_tokens : Array(DroppedToken) |
Cedarling::Response |
decision : Decision, diagnostics : Diagnostics (reasons, errors) |
Cedarling::DroppedToken |
mapping, index, reason : DropReasonInfo (variant : DropReason) |
Cedarling::BatchItemError |
category, item_index, message |
Cedarling::DataEntry |
key, value, data_type, created_at, expires_at, access_count |
Cedarling::DataStoreStats |
entry_count, max_entries, max_entry_size, total_size_bytes, avg_entry_size_bytes, capacity_usage_percent, memory_alert_threshold, memory_alert_triggered, metrics_enabled |
Cedarling::MetricsSnapshot |
policy_stats, error_counters, operational_stats, interval |
Batch results are BatchItemUnsignedOutcome::Success(result) / ::Failed(error) and the multi-issuer equivalents.
Multi-issuer token drop reasons (DropReason variants): InvalidInput, JwtValidationFailed, DuplicateToken, DuplicateMapping, NoProcessorRegistered, CustomProcessingFailed, CustomProcessingTimedOut, EntityBuildFailed.
Errors
All errors are Crystal exceptions under CedarlingUniffi (aliased as Cedarling::CedarlingError for the initialization error):
| Error | Variants |
|---|---|
CedarlingError |
InitializationFailed (config, policy store, schema, issuer loading, archive) |
AuthorizeError |
AuthorizationFailed, InvalidContext, InvalidInput |
DataError |
InvalidKey, KeyNotFound, StorageLimitExceeded, TtlExceeded, ValueTooLarge, SerializationError |
LogError |
LoggingFailed |
MetricsError |
NotEnabled, LockTelemetry |
begin
cedarling = Cedarling.load_from_json(config)
rescue error : Cedarling::CedarlingError
abort "cannot start Cedarling: #{error.message}"
end
Every generated type also lives under CedarlingUniffi (CedarlingUniffi::AuthorizeError, CedarlingUniffi::BatchItem, ...), so you can use the generated names directly when Cedarling's aliases do not cover a type.
Regenerating the bindings
scripts/generate.sh
Environment variables:
CEDARLING_RUST_DIR—jans-cedarlingcheckout (default../jans/jans-cedarling)UNIFFI_BINDGEN_CRYSTAL_DIR—uniffi-bindgen-crystalcheckout (default: use the binary onPATH)PROFILE—release(default) ordebug
The script bumps uniffi/uniffi_macros to 0.33 if needed, builds cedarling_uniffi, regenerates src/bindings/, and formats the output.
Run the specs against a built library with:
CEDARLING_LIB_DIR=/path/to/target/release scripts/spec.sh
Troubleshooting
| Symptom | Cause / fix |
|---|---|
libcedarling_uniffi.so: cannot open shared object file |
Set LD_LIBRARY_PATH (Linux) / DYLD_LIBRARY_PATH (macOS) to the library directory |
ContractMismatchError |
The library was built with another UniFFI version; rebuild it against 0.33 |
ChecksumMismatchError |
The library and src/bindings/ are out of sync; regenerate |
recursion limit reached / AuthorizationFailed from a fiber |
Use Cedarling.on_thread { ... } |
Failed to read file '.../._allow-...cedar' |
macOS AppleDouble files in the policy store; remove them (find policy-store -name '._*' -delete) |
InitializationFailed: ... schema ... |
The request entity attributes do not match schema.cedarschema |
Vendor documentation
- UniFFI binding for Cedarling — the interface these bindings expose.
- Authorization — unsigned, multi-issuer, batch, options and TRACE.
- Policy Store — directory,
.cjar, YAML formats and trusted issuers. - Properties — every bootstrap property.
- Entities, JWT Validation, Logs.
- Cedar policy language — permit/forbid, scope, conditions and annotations.
Contributing
- Fork it (https://github.com/dsisnero/cedarling/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Generated code changes belong in a separate commit from hand-written changes so the regeneration diff stays reviewable.
License
The shard is MIT licensed. The bindings are generated from Cedarling, which is Apache-2.0 licensed.
cedarling
- 0
- 0
- 0
- 0
- 0
- about 1 hour ago
- December 6, 2026
MIT License
Sun, 06 Dec 2026 00:44:07 GMT