dogwood.native#
Native PyO3 wrappers around the Rust dogwood_language API.
The functions in this module are the closest Python surface to the reference Rust implementation described in Dogwood’s API and workflow guide.
Mapping to Rust:
NativeAuthorizerwrapsdogwood_language::Authorizer::new(LoweredPolicySet)and feeds request events throughAuthorizer::is_authorized.lower_to_cedar()maps toLoweredPolicySet::from_str(...).as_cedar().cedar_schema()maps toLoweredPolicySet::cedar_schema_str().validate_policy()maps toValidator::new().validate(&policies).replay()maps todogwood_language::replay_log.
All schema-backed operations require the maturin-built extension module
dogwood._dogwood_native.
Functions
|
One-shot native authorization. |
Return whether the Rust |
|
|
Return the augmented Cedar schema emitted by Dogwood lowering. |
|
Lower Dogwood policy source to Cedar policy text. |
|
Replay a Dogwood trace and return CLI-style verdict lines. |
Raise |
|
|
Validate policy source against the supplied schemas. |
Classes
|
Persistent native Dogwood authorizer. |
- dogwood.native.available() bool[source]#
Return whether the Rust
dogwood_languageextension is importable.
- dogwood.native.require_available() None[source]#
Raise
RuntimeErrorif the native Rust extension is unavailable.
- class dogwood.native.NativeAuthorizer(policy_source: str, policy_schema_source: str, event_schema_source: str | None = None)[source]#
Persistent native Dogwood authorizer.
Rust mapping:
Builds
ServiceSchemafromevent_schema_sourceorServiceSchema::defaults().Builds
PolicySchema::from_cedarschema_str(policy_schema_source).Lowers with
LoweredPolicySet::from_str.Stores
dogwood_language::Authorizerand callsAuthorizer::is_authorizedfor each request.
The object is stateful: every authorization call records the event in the underlying Rust authorizer history, so temporal policies can observe prior events.
- __init__(policy_source: str, policy_schema_source: str, event_schema_source: str | None = None)[source]#
- authorize_request(action: str, principal: str, resource: str, input: dict[str, Any]) str[source]#
Authorize one request event and return
"Allow"or"Deny".Rust mapping: builds a
dogwood_language::Eventwith kind"request"from the supplied action, principal, resource, and input, then callsAuthorizer::is_authorized.
- dogwood.native.lower_to_cedar(policy_source: str, policy_schema_source: str, event_schema_source: str | None = None) str[source]#
Lower Dogwood policy source to Cedar policy text.
Rust mapping:
LoweredPolicySet::from_strfollowed byLoweredPolicySet::as_cedarrendering.
- dogwood.native.cedar_schema(policy_source: str, policy_schema_source: str, event_schema_source: str | None = None) str[source]#
Return the augmented Cedar schema emitted by Dogwood lowering.
Rust mapping:
LoweredPolicySet::cedar_schema_str.
- dogwood.native.validate_policy(policy_source: str, policy_schema_source: str, event_schema_source: str | None = None) dict[str, Any][source]#
Validate policy source against the supplied schemas.
Rust mapping:
LoweredPolicySet::from_strthenValidator::new().validate(&policies).
- dogwood.native.replay(policy_source: str, policy_schema_source: str, trace_source: str, event_schema_source: str | None = None) str[source]#
Replay a Dogwood trace and return CLI-style verdict lines.
Rust mapping:
dogwood_language::replay_logafter lowering the policy set against the provided action and optional event schemas.
- dogwood.native.authorize_request(policy_source: str, policy_schema_source: str, action: str, principal: str, resource: str, input: dict[str, Any], event_schema_source: str | None = None) str[source]#
One-shot native authorization.
Rust mapping: lower policy source into a fresh
LoweredPolicySet, create a freshAuthorizer, build onerequestevent, and callAuthorizer::is_authorized. PreferNativeAuthorizerfor repeated decisions so parse/lower work happens once.