{"id":17543398,"url":"https://github.com/darrenbaldwin07/clerk-rs","last_synced_at":"2025-05-16T00:07:24.639Z","repository":{"id":153085833,"uuid":"622972243","full_name":"DarrenBaldwin07/clerk-rs","owner":"DarrenBaldwin07","description":"The official community-maintained Clerk SDK for Rust","archived":false,"fork":false,"pushed_at":"2025-05-01T01:26:01.000Z","size":432,"stargazers_count":115,"open_issues_count":7,"forks_count":33,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-05-13T03:03:25.570Z","etag":null,"topics":["actix-web","authentication","authorization","axum","clerk","jwt","rust","sdk"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/clerk-rs","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DarrenBaldwin07.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.MD","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,"publiccode":null,"codemeta":null}},"created_at":"2023-04-03T12:45:30.000Z","updated_at":"2025-05-08T10:08:11.000Z","dependencies_parsed_at":"2024-02-22T21:30:52.876Z","dependency_job_id":"da13c354-828a-4963-ad40-3c099533722a","html_url":"https://github.com/DarrenBaldwin07/clerk-rs","commit_stats":{"total_commits":148,"total_committers":20,"mean_commits":7.4,"dds":"0.28378378378378377","last_synced_commit":"8b6e205eede59d804548bbfa06776c2c85796b86"},"previous_names":["darrenbaldwin07/clerk-rs","cincinnati-ventures/clerk-rs"],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DarrenBaldwin07%2Fclerk-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DarrenBaldwin07%2Fclerk-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DarrenBaldwin07%2Fclerk-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DarrenBaldwin07%2Fclerk-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DarrenBaldwin07","download_url":"https://codeload.github.com/DarrenBaldwin07/clerk-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253863063,"owners_count":21975593,"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":["actix-web","authentication","authorization","axum","clerk","jwt","rust","sdk"],"created_at":"2024-10-21T00:24:02.349Z","updated_at":"2025-05-16T00:07:19.561Z","avatar_url":"https://github.com/DarrenBaldwin07.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![crates.io](https://img.shields.io/crates/v/clerk-rs?style=flat-square)](https://crates.io/crates/clerk-rs)\n[![Downloads](https://img.shields.io/crates/d/clerk-rs.svg?style=flat-square)](https://crates.io/crates/clerk-rs)\n[![docs.rs](https://img.shields.io/docsrs/clerk-rs?style=flat-square)](https://docs.rs/clerk-rs)\n\n# The official community-maintained Clerk SDK for Rust\n\nFor more detailed documentation, please reference the below links:\n\n- [Official Clerk Backend API docs](https://clerk.com/docs/reference/backend-api)\n- [Clerk-rs SDK API docs](https://github.com/DarrenBaldwin07/clerk-rs/blob/main/docs.md)\n\n\u003e This SDK is updated frequently to keep up with any changes to the actual Clerk API. If you see anything that needs updating or is not inline with the official Clerk api, please open an issue!\n\n## Examples\n\n\u003e Check out examples in the `/examples` directory\n\n### Using a traditional http request to a valid clerk endpoint:\n\n```rust\nuse tokio;\nuse clerk_rs::{clerk::Clerk, ClerkConfiguration, endpoints::ClerkGetEndpoint};\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    let config = ClerkConfiguration::new(None, None, Some(\"sk_test_key\".to_string()), None);\n    let client = Clerk::new(config);\n\n    let res = client.get(ClerkGetEndpoint::GetUserList).await?;\n\n    Ok(())\n}\n```\n\n### Using a clerk-rs method:\n\n```rust\nuse tokio;\nuse clerk_rs::{clerk::Clerk, ClerkConfiguration, apis::emails_api::Email};\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    let config = ClerkConfiguration::new(None, None, Some(\"sk_test_key\".to_string()), None);\n    let client = Clerk::new(config);\n\n    Email::create(\u0026client, Some(your_clerk_email));\n\n    Ok(())\n}\n```\n\n### Protecting a actix-web endpoint with Clerk.dev:\n\nWith the `actix` feature enabled:\n\n```rust\nuse actix_web::{web, App, HttpServer, Responder};\nuse clerk_rs::{\n    clerk::Clerk,\n    validators::{actix::ClerkMiddleware, jwks::MemoryCacheJwksProvider},\n    ClerkConfiguration,\n};\n\nasync fn index() -\u003e impl Responder {\n    \"Hello world!\"\n}\n\n#[actix_web::main]\nasync fn main() -\u003e std::io::Result\u003c()\u003e {\n    HttpServer::new(|| {\n        let config = ClerkConfiguration::new(None, None, Some(\"your_secret_key\".to_string()), None);\n        let clerk = Clerk::new(config);\n\n        App::new()\n            .wrap(ClerkMiddleware::new(MemoryCacheJwksProvider::new(clerk), None, true))\n            .route(\"/index\", web::get().to(index))\n    })\n    .bind((\"127.0.0.1\", 8080))?\n    .run()\n    .await\n}\n```\n\n### Protecting a axum endpoint with Clerk.dev:\n\nWith the `axum` feature enabled:\n\n```rust\nuse axum::{routing::get, Router};\nuse clerk_rs::{\n    clerk::Clerk,\n    validators::{axum::ClerkLayer, jwks::MemoryCacheJwksProvider},\n    ClerkConfiguration,\n};\n\nasync fn index() -\u003e \u0026'static str {\n    \"Hello world!\"\n}\n\n#[tokio::main]\nasync fn main() -\u003e std::io::Result\u003c()\u003e {\n    let config = ClerkConfiguration::new(None, None, Some(\"your_secret_key\".to_string()), None);\n    let clerk = Clerk::new(config);\n\n    let app = Router::new()\n        .route(\"/index\", get(index))\n        .layer(ClerkLayer::new(MemoryCacheJwksProvider::new(clerk), None, true));\n\n    let listener = tokio::net::TcpListener::bind(\"0.0.0.0:8080\").await?;\n    axum::serve(listener, app).await\n}\n```\n\n### Protecting a rocket endpoint with Clerk.dev:\n\nWith the `rocket` feature enabled:\n\n```rust\nuse clerk_rs::{\n\tclerk::Clerk,\n\tvalidators::{\n\t\tjwks::MemoryCacheJwksProvider,\n\t\trocket::{ClerkGuard, ClerkGuardConfig},\n\t},\n\tClerkConfiguration,\n};\nuse rocket::{\n\tget, launch, routes,\n\tserde::{Deserialize, Serialize},\n};\n\n#[derive(Serialize, Deserialize)]\nstruct Message {\n\tcontent: String,\n}\n\n#[get(\"/\")]\nfn index(jwt: ClerkGuard\u003cMemoryCacheJwksProvider\u003e) -\u003e \u0026'static str {\n\t\"Hello world!\"\n}\n\n#[launch]\nfn rocket() -\u003e _ {\n\tlet config = ClerkConfiguration::new(None, None, Some(\"sk_test_F9HM5l3WMTDMdBB0ygcMMAiL37QA6BvXYV1v18Noit\".to_string()), None);\n\tlet clerk = Clerk::new(config);\n\tlet clerk_config = ClerkGuardConfig::new(\n\t\tMemoryCacheJwksProvider::new(clerk),\n\t\tNone,\n\t\ttrue, // validate_session_cookie\n\t);\n\n\trocket::build().mount(\"/\", routes![index]).manage(clerk_config)\n}\n\n```\n\n### Protecting a Poem endpoint with Clerk\n\nWith the `poem` feature enabled and poem v3 installed:\n```rust\nuse clerk_rs::{\n    clerk::Clerk,\n    validators::{jwks::MemoryCacheJwksProvider, poem::ClerkPoemMiddleware},\n    ClerkConfiguration,\n};\nuse poem::{get, handler, listener::TcpListener, web::Path, EndpointExt, Route, Server};\n\n#[handler]\nfn hello(Path(name): Path\u003cString\u003e) -\u003e String {\n    format!(\"hello: {}\", name)\n}\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c(), std::io::Error\u003e {\n    let clerk = Clerk::new(ClerkConfiguration::new(\n        None,\n        None,\n        Some(\"sk_test_F9HM5l3WMTDMdBB0ygcMMAiL37QA6BvXYV1v18Noit\".to_owned()),\n        None,\n    ));\n    // Initialize middleware.\n    let clerk_poem_middleware = ClerkPoemMiddleware::new(\n        MemoryCacheJwksProvider::new(clerk.clone()),\n        true,\n        // If you're using poem-openapi, you may need this to exclude some routes from auth\n        // verification.\n        Some(vec![\"/some/route/to/exclude\".to_owned()]),\n    );\n\n    let app = Route::new()\n        .at(\"/hello/:name\", get(hello))\n        .with(clerk_poem_middleware); // Add middleware here (EndpointExt needs to be in scope).\n\n    Server::new(TcpListener::bind(\"0.0.0.0:3000\"))\n        .run(app)\n        .await\n}\n```\n\nThe JWT can be accessed using `Data\u003c\u0026ClerkJwt\u003e` (or `req.data::\u003cClerkJwt\u003e()`).\n\n## Roadmap\n\n- [ ] Support other http clients along with the default reqwest client (like hyper)\n- [ ] Tokio and async-std async runtimes for hyper clients\n- [ ] Optional reqwest blocking client\n- [x] Support authorization via \\_\\_session cookie on same-origin\n- [ ] Add validator support for axum, rocket, warp\n\n# Production users\n\n- [Tembo](https://tembo.io)\n- [Rezon](https://rezon.ai)\n- [Gitar](https://gitar.co)\n- [Have I Been Squatted](https://haveibeensquatted.com)\n- Open a PR and add your company here :)\n\n\u003c/br\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarrenbaldwin07%2Fclerk-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdarrenbaldwin07%2Fclerk-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarrenbaldwin07%2Fclerk-rs/lists"}