{"id":13822766,"url":"https://github.com/marcocastignoli/rust_rocket_api_authentication","last_synced_at":"2025-10-23T13:31:11.978Z","repository":{"id":99361677,"uuid":"142282446","full_name":"marcocastignoli/rust_rocket_api_authentication","owner":"marcocastignoli","description":"An example of API written in Rust with the rocket.rs framework, with a JWT Authentication ","archived":false,"fork":false,"pushed_at":"2018-10-15T17:28:48.000Z","size":22,"stargazers_count":122,"open_issues_count":0,"forks_count":17,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-01-30T18:51:59.552Z","etag":null,"topics":["api","authentication","rocket","rust","tutorial","web","webservice"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marcocastignoli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-07-25T10:05:43.000Z","updated_at":"2024-12-06T14:38:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"5477847c-6560-4e85-beca-992a584cd0ac","html_url":"https://github.com/marcocastignoli/rust_rocket_api_authentication","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcocastignoli%2Frust_rocket_api_authentication","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcocastignoli%2Frust_rocket_api_authentication/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcocastignoli%2Frust_rocket_api_authentication/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcocastignoli%2Frust_rocket_api_authentication/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcocastignoli","download_url":"https://codeload.github.com/marcocastignoli/rust_rocket_api_authentication/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237834754,"owners_count":19373786,"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":["api","authentication","rocket","rust","tutorial","web","webservice"],"created_at":"2024-08-04T08:02:16.346Z","updated_at":"2025-10-23T13:31:11.566Z","avatar_url":"https://github.com/marcocastignoli.png","language":"Rust","readme":"# Rust rocket.rs - API with Authentication\n\nAn example of API written in Rust with the rocket.rs framework, with a JWT Authentication \n\n## Requirements\n\n1. Configure Rust to satisfy rocket.rs dependencies\n\n## Installation\n\n1. First run the migration\n    ```bash\n    diesel migration run\n    ```\n2. Compile the code setting the DATABASE_URL environment variable\n    ```bash\n        export DATABASE_URL=mysql://username:password@localhost/heroes \u0026\u0026 cargo run\n    ```\n\n## API\n\n### /auth/login\nGet a jwt token for the user marcocastignoli\n```bash\ncurl -X POST \\\n  http://localhost:8000/auth/login \\\n  -H 'content-type: application/json' \\\n  -d '{\n\t\"username\": \"marcocastignoli\",\n\t\"password\": \"12345\"\n}'\n```\n### /user\nCall a protected route (use the token returned from the /auth/login API)\n```bash\ncurl -X GET \\\n  http://localhost:8000/user \\\n  -H 'authentication: eyJ0eXAiOiJKV1QiLCJraWQiOm51bGwsImFsZyI6IkhTMjU2In0.eyJpc3MiOm51bGwsInN1YiI6Im1hcmNvY2FzdGlnbm9saSIsImF1ZCI6bnVsbCwiZXhwIjpudWxsLCJuYmYiOm51bGwsImlhdCI6bnVsbCwianRpIjpudWxsfQ.fnp0D8Qh1bTFv1zKTVGAxwjtyTCOqKuarRzBQabjiCI'\n```\n\n## Thanks\nSpecial thanks to @sean3z for this repo https://github.com/sean3z/rocket-diesel-rest-api-example and this tutorial https://medium.com/sean3z/building-a-restful-crud-api-with-rust-1867308352d8","funding_links":[],"categories":["Rust"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcocastignoli%2Frust_rocket_api_authentication","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcocastignoli%2Frust_rocket_api_authentication","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcocastignoli%2Frust_rocket_api_authentication/lists"}