{"id":18715169,"url":"https://github.com/cerbos/cerbos-sdk-rust","last_synced_at":"2025-04-12T13:07:57.220Z","repository":{"id":37743777,"uuid":"481260465","full_name":"cerbos/cerbos-sdk-rust","owner":"cerbos","description":"Cerbos Rust SDK","archived":false,"fork":false,"pushed_at":"2024-04-02T06:12:20.000Z","size":242,"stargazers_count":6,"open_issues_count":1,"forks_count":2,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-04-02T07:30:05.196Z","etag":null,"topics":["access-control","api-client","authorization","authz","cerbos","rust","rust-library","security"],"latest_commit_sha":null,"homepage":"https://cerbos.dev","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cerbos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-04-13T14:56:48.000Z","updated_at":"2024-04-02T07:30:07.855Z","dependencies_parsed_at":"2023-09-22T08:08:51.169Z","dependency_job_id":"86f960cb-b388-4ada-b69a-38835cee9fe1","html_url":"https://github.com/cerbos/cerbos-sdk-rust","commit_stats":{"total_commits":13,"total_committers":3,"mean_commits":4.333333333333333,"dds":"0.23076923076923073","last_synced_commit":"2e5c11361edf6ad743eb6034d0ff2ee6d671e820"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cerbos%2Fcerbos-sdk-rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cerbos%2Fcerbos-sdk-rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cerbos%2Fcerbos-sdk-rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cerbos%2Fcerbos-sdk-rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cerbos","download_url":"https://codeload.github.com/cerbos/cerbos-sdk-rust/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223518539,"owners_count":17158689,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["access-control","api-client","authorization","authz","cerbos","rust","rust-library","security"],"created_at":"2024-11-07T13:07:49.341Z","updated_at":"2024-11-07T13:07:49.819Z","avatar_url":"https://github.com/cerbos.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cerbos Rust SDK\n\nRust client library for [Cerbos](https://cerbos.dev): the open core, language-agnostic, scalable authorization solution that makes user permissions and authorization simple to implement and manage by writing context-aware access control policies for your application resources.\n\n* [Cerbos website](https://cerbos.dev)\n* [Cerbos documentation](https://docs.cerbos.dev)\n* [Cerbos GitHub repository](https://github.com/cerbos/cerbos)\n* [Cerbos Slack community](http://go.cerbos.io/slack)\n\n\n## Usage\n\n```\ncargo add cerbos\n```\n\nThe client can be used either asynchronously or synchronously by instantiating `CerbosAsyncClient`\nor `CerbosSyncClient` respectively.\n\n\n```rust\nuse cerbos::sdk::attr::attr;\nuse cerbos::sdk::model::{Principal, Resource};\nuse cerbos::sdk::{CerbosAsyncClient, CerbosClientOptions, CerbosEndpoint, Result};\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c()\u003e {\n    let opt = CerbosClientOptions::new(CerbosEndpoint::HostPort(\"localhost\", 3593));\n    let mut client = CerbosAsyncClient::new(opt).await?;\n\n    let principal = Principal::new(\"alice\", [\"employee\"])\n        .with_policy_version(\"20210210\")\n        .with_attributes([\n            attr(\"department\", \"marketing\"),\n            attr(\"geography\", \"GB\"),\n            attr(\"team\", \"design\"),\n        ]);\n\n    let resource = Resource::new(\"XX125\", \"leave_request\")\n        .with_policy_version(\"20210210\")\n        .with_attributes([\n            attr(\"department\", \"marketing\"),\n            attr(\"geography\", \"GB\"),\n            attr(\"team\", \"design\"),\n            attr(\"owner\", \"alice\"),\n            attr(\"approved\", true),\n            attr(\"id\", \"XX125\"),\n        ]);\n\n    let resp = client\n        .is_allowed(\"view:public\", principal, resource, None)\n        .await?;\n\n    println!(\"Allowed={:?}\", resp);\n\n    Ok(())\n}\n\n```\n\n## Development\n\nRunning tests\n\n```sh\ncerbos run --set=storage.disk.directory=resources/store -- cargo test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcerbos%2Fcerbos-sdk-rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcerbos%2Fcerbos-sdk-rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcerbos%2Fcerbos-sdk-rust/lists"}