Skip to content

alexsayantan/actix-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ JWT-Based Authentication System with Actix Web

Welcome to the JWT-Based Authentication System built with Actix Web in Rust! This project leverages the security, scalability and speed of Actix Web to provide a robust and secure authentication system.

🌟 Features

  • Role-Based Authentication: Secure access with role-based permissions.
  • Argon2 Password Hashing: Enhanced security with Argon2 hashing.
  • User Registration: Easy user sign-up process.
  • Login with Token Generation: Secure login with JWT token generation.
  • Token Removal with Logout API: Seamless logout functionality.
  • Admin Role: Admins can view the list of users.
  • User Details: Logged-in users can view their own details.
  • Swagger UI: Integrated Swagger UI for easy API documentation.
  • Production-Level Structure: Organized and maintainable project structure.
  • PostgreSQL Connectivity: Reliable database connectivity with PostgreSQL.
  • Middleware for Route Guarding: Secure routes with custom middleware.

πŸ“š Documentation

Explore the API documentation with Swagger UI:

Swagger UI

πŸ› οΈ Installation

  1. Clone the repository:

    https://github.com/alexsayantan/actix-auth.git
    cd jwt-auth-actix-web
  2. Set up PostgreSQL:

    • Ensure you have PostgreSQL installed and running.
    • Create a database and update the connection string in the .env file.
  3. Run the application:

    cargo run

🧩 Usage

  • Register a new user:

    POST /api/auth/register
  • Login and get a token:

    POST /api/auth/login
  • Logout and remove the token:

    POST /api/auth/logout
  • View user list (Admin only):

    GET /api/users
  • View logged-in user details:

    GET /api/users/me

πŸ—οΈ Project Structure

src/
β”œβ”€β”€ handlers/
β”‚   β”œβ”€β”€ auth.rs
β”‚   β”œβ”€β”€ mod.rs
β”‚   └── users.rs
β”œβ”€β”€ routes/
β”‚   β”œβ”€β”€ auth.rs
β”‚   β”œβ”€β”€ heath.rs
β”‚   β”œβ”€β”€ mod.rs
β”‚   └── users.rs
└── utils/
β”‚   β”œβ”€β”€ mod.rs
β”‚   β”œβ”€β”€ password.rs
β”‚   └── token.rs
β”œβ”€β”€ auth.rs
β”œβ”€β”€ config.rs
β”œβ”€β”€ db.rs
β”œβ”€β”€ dtos.rs
β”œβ”€β”€ error.rs
β”œβ”€β”€ main.rs
└── models.rs

🀝 Contributing

Contributions are welcome! Please fork this repository and submit a pull request.

About

πŸš€πŸ” Discover a secure and scalable authentication solution with our JWT-Based Authentication System using Actix Web in Rust! πŸ‘₯πŸ”‘ Features include role-based authentication, Argon2 password hashing, user registration, login with token generation, and logout API. Admins can view user lists, and logged in users can access their details.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages