Skip to main content

Crate treetop_client

Crate treetop_client 

Source
Expand description

Typed async Rust client for Treetop policy authorization servers.

Treetop is a Cedar-based policy evaluation service. This crate provides a strongly typed, async client for evaluating authorization requests, managing policies, and querying server status over the Treetop REST API.

§Quick start

use treetop_client::{Action, Client, Request, Resource, User};

let client = Client::builder("https://treetop.example.com").build()?;

let allowed = client
    .is_allowed(Request::new(
        User::new("alice").unwrap(),
        Action::new("view").unwrap(),
        Resource::new("Document", "doc-42").unwrap(),
    ))
    .await?;

§Connection pooling

The Client reuses connections via reqwest’s built-in connection pool. Create one Client and share it across your application. Cloning a Client (e.g. via Client::with_correlation_id) shares the same underlying pool at zero cost.

§Security

Upload tokens are stored using secrecy::SecretString, which zeroizes memory on drop and is redacted in Debug output. TLS uses rustls by default without an OpenSSL/system-TLS dependency. Request-domain fields are private and validated before transport, redirects are disabled on the default HTTP client, and request and successful-response bodies have configurable size limits.

Re-exports§

pub use client::Authorization;
pub use client::CanUpload;
pub use client::Client;
pub use client::ClientBuilder;
pub use client::DetailedAuthorization;
pub use client::RawUserPoliciesRequest;
pub use client::ReadOnly;
pub use client::UserPoliciesRequest;
pub use error::Result;
pub use error::TreetopError;
pub use token::UploadToken;
pub use types::Action;
pub use types::AttrValue;
pub use types::AuthRequest;
pub use types::AuthorizeBriefResponse;
pub use types::AuthorizeDecisionBrief;
pub use types::AuthorizeDecisionDetailed;
pub use types::AuthorizeDetailedResponse;
pub use types::AuthorizeRequest;
pub use types::AuthorizeResponse;
pub use types::BatchResult;
pub use types::CedarIpAddr;
pub use types::Core;
pub use types::DecisionBrief;
pub use types::Group;
pub use types::IndexedResult;
pub use types::Metadata;
pub use types::MetadataSource;
pub use types::PermitPolicy;
pub use types::PoliciesDownload;
pub use types::PoliciesMetadata;
pub use types::PolicyMatch;
pub use types::PolicyMatchReason;
pub use types::PolicyVersion;
pub use types::Principal;
pub use types::Request;
pub use types::RequestContextFallbackReason;
pub use types::RequestContextStatus;
pub use types::RequestLimits;
pub use types::Resource;
pub use types::SchemaDownload;
pub use types::StatusResponse;
pub use types::User;
pub use types::UserPolicies;
pub use types::ValidationError;
pub use types::VersionInfo;

Modules§

client
HTTP client for communicating with Treetop servers.
error
Error types for the Treetop client.
token
Secure upload token handling.
types
Types for the Treetop REST API, wire-compatible with treetop-core and treetop-rest v0.0.7.