{"id":21800994,"url":"https://github.com/wpcodevo/rust-axum-jwt-rs256","last_synced_at":"2025-04-13T18:23:26.334Z","repository":{"id":214316774,"uuid":"623185181","full_name":"wpcodevo/rust-axum-jwt-rs256","owner":"wpcodevo","description":"In this article, you'll learn how to build a secure and efficient backend API in Rust with JWT access and refresh tokens functionality. We'll leverage the high-performance Axum framework and SQLX to store data in a PostgreSQL database.","archived":false,"fork":false,"pushed_at":"2023-12-27T10:14:54.000Z","size":64,"stargazers_count":49,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T09:11:32.285Z","etag":null,"topics":["assymetric-encryption","authentication","axum","axum-framework","docker","jsonwebtoken","jwt","jwt-authentication","postgresql","private-keys","public-keys","rs256","rust"],"latest_commit_sha":null,"homepage":"https://codevoweb.com/rust-and-axum-jwt-access-and-refresh-tokens/","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/wpcodevo.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":"2023-04-03T21:41:38.000Z","updated_at":"2025-02-07T09:42:49.000Z","dependencies_parsed_at":"2023-12-27T11:26:46.564Z","dependency_job_id":"72b10bd6-f79c-4524-b8d7-a81c241fd796","html_url":"https://github.com/wpcodevo/rust-axum-jwt-rs256","commit_stats":null,"previous_names":["wpcodevo/rust-axum-jwt-rs256"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wpcodevo%2Frust-axum-jwt-rs256","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wpcodevo%2Frust-axum-jwt-rs256/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wpcodevo%2Frust-axum-jwt-rs256/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wpcodevo%2Frust-axum-jwt-rs256/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wpcodevo","download_url":"https://codeload.github.com/wpcodevo/rust-axum-jwt-rs256/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248759143,"owners_count":21157098,"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":["assymetric-encryption","authentication","axum","axum-framework","docker","jsonwebtoken","jwt","jwt-authentication","postgresql","private-keys","public-keys","rs256","rust"],"created_at":"2024-11-27T11:15:35.791Z","updated_at":"2025-04-13T18:23:26.300Z","avatar_url":"https://github.com/wpcodevo.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rust and Axum Framework: JWT Access and Refresh Tokens\n\nIn this article, you'll learn how to build a secure and efficient backend API in Rust with JWT access and refresh tokens functionality. We'll leverage the high-performance Axum framework and SQLX to store data in a PostgreSQL database.\n\n![Rust and Axum Framework: JWT Access and Refresh Tokens](https://codevoweb.com/wp-content/uploads/2023/04/Rust-and-Axum-Framework-JWT-Access-and-Refresh-Tokens.webp)\n\n## Topics Covered\n\n- Set up and Run the Axum API on your Machine\n- Run the Axum API with a Frontend App\n- Set up the Rust Project with Cargo\n- Launch PostgreSQL, Redis and pgAdmin Servers\n- Perform Database Migration with SQLx-CLI\n- Load the Environment Variables into the App\n- Connect the Axum Server to the Redis and Postgres Servers\n- Define the SQLX Database Model\n- Define the API Response Structs\n- Generate the RS256 Private and Public Keys\n- Create Helper Functions to Sign and Verify the JWTs\n    - Function to Sign the JWT using the Private Key\n    - Function to Verify the JWT using the Public Key\n- Create an Axum JWT Middleware Guard\n- Implement the JWT Authentication Route Handlers\n    - Create Utility Functions\n    - Route Handler to Register Users\n    - Route Handler to Sign In Users\n    - Route Handler to Refresh the JWTs\n    - Route Handler to Logout Users\n    - Route Handler to Fetch the Authenticated User\n    - The Complete Code of the Route Handlers\n- Create Axum Routes for the Handler Functions\n- Register the Axum Router and Set up CORS\n- Conclusion\n\n\nRead the entire article here: [https://codevoweb.com/rust-and-axum-jwt-access-and-refresh-tokens/](https://codevoweb.com/rust-and-axum-jwt-access-and-refresh-tokens/)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwpcodevo%2Frust-axum-jwt-rs256","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwpcodevo%2Frust-axum-jwt-rs256","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwpcodevo%2Frust-axum-jwt-rs256/lists"}