{"id":26120126,"url":"https://github.com/eclipse-biscuit/biscuit-actix-middleware","last_synced_at":"2026-06-05T05:31:47.314Z","repository":{"id":164460197,"uuid":"635352153","full_name":"eclipse-biscuit/biscuit-actix-middleware","owner":"eclipse-biscuit","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-16T18:46:53.000Z","size":103,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-10T13:06:03.147Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/eclipse-biscuit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"publiccode":null,"codemeta":null}},"created_at":"2023-05-02T14:06:41.000Z","updated_at":"2025-02-21T12:53:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"9f30cfc2-8d0c-4556-9dee-77eb403118a7","html_url":"https://github.com/eclipse-biscuit/biscuit-actix-middleware","commit_stats":null,"previous_names":["eclipse-biscuit/biscuit-actix-middleware"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eclipse-biscuit%2Fbiscuit-actix-middleware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eclipse-biscuit%2Fbiscuit-actix-middleware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eclipse-biscuit%2Fbiscuit-actix-middleware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eclipse-biscuit%2Fbiscuit-actix-middleware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eclipse-biscuit","download_url":"https://codeload.github.com/eclipse-biscuit/biscuit-actix-middleware/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242856025,"owners_count":20196360,"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":[],"created_at":"2025-03-10T13:06:08.572Z","updated_at":"2025-12-16T04:31:44.968Z","avatar_url":"https://github.com/eclipse-biscuit.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Biscuit actix middleware\n\nThis middleware allows service-wide extraction and parsing of [biscuit][biscuit] tokens.\n\n**Authorization itself still need to be handled from within endpoint handlers.**\n\nThe middleware expects a base64-encoded token through the [bearer token HTTP authorization scheme][bearer-token-auth] (an `Authorization: Bearer \u003ctoken\u003e` HTTP header). This token is deserialized and its cryptographic signatures verified with the provided public key.\n\n- Requests without a bearer token are rejected with a HTTP `401 Unauthorized` error;\n- Requests with tokens that fail parsing or cryptographic verification are rejected with a HTTP `403 Forbidden` error.\n\nToken extraction logic and error handling are configurable (see [Configuration example](./examples/configuration.rs)).\n\n## Working example\n\nHere is a web server exposing `GET /hello`, only to tokens containing the `role(\"admin\")` fact. The public key used for verifying tokens is provided through the `BISCUIT_PUBLIC_KEY` environment variable.\n\nA complete, runnable example can be found in `examples/readme.rs`, and can be run with `BISCUIT_PUBLIC_KEY=\u003cpublic key\u003e cargo run --example readme`.\n\nOptionally, you can enable tracing by running `BISCUIT_PUBLIC_KEY=\u003cpublic key\u003e cargo run --example readme --features tracing` to observe middleware traces as logs in the console.\n\n```rust\nuse actix_web::{get, web, App, HttpResponse, HttpServer};\nuse biscuit_actix_middleware::BiscuitMiddleware;\nuse biscuit_auth::{macros::*, Biscuit, PublicKey};\n\n#[actix_web::main]\nasync fn main() -\u003e std::io::Result\u003c()\u003e {\n    let public_key = PublicKey::from_bytes_hex(\n        \u0026std::env::var(\"BISCUIT_PUBLIC_KEY\")\n            .expect(\"Missing BISCUIT_PUBLIC_KEY environment variable\"),\n    )\n    .expect(\"Couldn't parse public key\");\n\n    HttpServer::new(move || {\n        App::new()\n            .wrap(BiscuitMiddleware::new(public_key))\n            .service(hello)\n    })\n    .bind((\"127.0.0.1\", 8080))?\n    .run()\n    .await\n}\n\n#[get(\"/hello\")]\nasync fn hello(biscuit: web::ReqData\u003cBiscuit\u003e) -\u003e HttpResponse {\n    let mut authorizer = authorizer!(\n        r#\"\n      allow if role(\"admin\");\n    \"#\n    );\n\n    authorizer.add_token(\u0026biscuit).unwrap();\n    if authorizer.authorize().is_err() {\n        return HttpResponse::Forbidden().finish();\n    }\n\n    HttpResponse::Ok().body(\"Hello admin!\")\n}\n\n```\n\n[biscuit]: https://biscuitsec.org\n[bearer-token-auth]: https://datatracker.ietf.org/doc/html/rfc6750#section-2.1\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feclipse-biscuit%2Fbiscuit-actix-middleware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feclipse-biscuit%2Fbiscuit-actix-middleware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feclipse-biscuit%2Fbiscuit-actix-middleware/lists"}