{"id":19137755,"url":"https://github.com/pepsighan/basic-auth-raw","last_synced_at":"2025-07-12T15:39:43.525Z","repository":{"id":57503193,"uuid":"129913018","full_name":"pepsighan/basic-auth-raw","owner":"pepsighan","description":"A base for Basic Authentication over which a concrete authentication mechanism can be built","archived":false,"fork":false,"pushed_at":"2018-05-16T09:38:07.000Z","size":10,"stargazers_count":0,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-23T08:07:43.545Z","etag":null,"topics":["basic-authentication","rocket-rs"],"latest_commit_sha":null,"homepage":null,"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/pepsighan.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}},"created_at":"2018-04-17T13:59:04.000Z","updated_at":"2018-05-16T09:38:08.000Z","dependencies_parsed_at":"2022-09-13T08:21:57.048Z","dependency_job_id":null,"html_url":"https://github.com/pepsighan/basic-auth-raw","commit_stats":null,"previous_names":["csharad/basic-auth-raw"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pepsighan%2Fbasic-auth-raw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pepsighan%2Fbasic-auth-raw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pepsighan%2Fbasic-auth-raw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pepsighan%2Fbasic-auth-raw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pepsighan","download_url":"https://codeload.github.com/pepsighan/basic-auth-raw/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240216970,"owners_count":19766683,"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":["basic-authentication","rocket-rs"],"created_at":"2024-11-09T06:40:31.467Z","updated_at":"2025-02-22T18:26:47.351Z","avatar_url":"https://github.com/pepsighan.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Raw Basic Authentication\n\nA [Rocket](https://github.com/SergioBenitez/Rocket) library to provide a base for\nBasic Authentication over which a concrete authentication mechanism can be built.\n\nThis library exports `BasicAuthRaw` which you could directly use on the request handler.\n#### Example\n\n```rust\nuse basic_auth_raw::BasicAuthRaw;\n\n#[get(\"/secure-path\")\nfn secret(basic: BasicAuthRaw) -\u003e String {\n    format!(\"Your username is {}\", basic.username);\n}\n```\n\nOr you could build Request Guards on top of it (Recommended).\n#### Example\n\n```rust\nuse basic_auth_raw::BasicAuthRaw;\n\nstruct Admin(User);\n\nimpl\u003c'a, 'r\u003e FromRequest\u003c'a, 'r\u003e for Admin {\n    type Error = ();\n\n    fn from_request(request: \u0026Request) -\u003e Outcome\u003cSelf, Self::Error\u003e {\n        let basic = BasicAuthRaw::from_request(request)?;\n        let user = User::from_db(basic.username, basic.password);\n        if user.is_admin {\n            Outcome::Success(user);\n        } else {\n            Outcome::Failure((Status::Unauthorized, ()));\n        }\n    }\n}\n\n#[get(\"/secure-path\")\nfn secret(admin: Admin) -\u003e String {\n    format!(\"Your username is {}\", admin.user.username);\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpepsighan%2Fbasic-auth-raw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpepsighan%2Fbasic-auth-raw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpepsighan%2Fbasic-auth-raw/lists"}