Skip to content

This project is a simple implementation of Role-Based Authentication using Spring Security. It demonstrates how to secure endpoints based on user roles and implement user authentication and authorization effectively.

Notifications You must be signed in to change notification settings

deepakmali-09/spring-security-p02-role-base-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Role-Based Authentication with Spring Security

This project is a simple implementation of Role-Based Authentication using Spring Security. It demonstrates how to secure endpoints based on user roles and implement user authentication and authorization effectively.


Features

  • User authentication with username and password.
  • Role-based access control (e.g., ADMIN, USER, etc.).
  • Secured endpoints accessible only by authorized roles.
  • Basic user data stored in memory for simplicity (can be replaced with a database).
  • JWT (JSON Web Tokens) implementation for authentication (if applicable).

Tech Stack

  • Java: Core programming language.
  • Spring Boot: Framework for application setup and configurations.
  • Spring Security: Security framework for authentication and authorization.
  • Maven: Build tool for managing dependencies and project lifecycle.
  • Postman (optional): For testing API endpoints.

Installation and Setup

  1. Clone the repository:

    git clone https://github.com/deepakmali-09/spring-security-p02-role-base-auth.git
    cd sspring-security-p02-role-base-auth
  2. Build the project using Maven:

    mvn clean install
  3. Run the application:

    mvn spring-boot:run
  4. Access the application:

    • Base URL: http://localhost:8080

Endpoints

Endpoint Method Role Required Description
/login POST Public Authenticate user
/transfer GET ADMIN Access restricted to ADMIN role
/update GET USER Access restricted to USER role

How to Test

  1. Use Postman or a similar tool to test API endpoints.
  2. Login with valid credentials to receive a token.

Project Structure

├── src/main/java
│   ├── com.deep.SpringSecurity-P02-RoleBaseAuth
│       ├── config          // Security configurations
│       ├── controllers     // REST controllers
└── pom.xml                // Maven dependencies

Future Enhancements

  • Integrate with a database (e.g., MySQL, MongoDB) for user management.
  • Add support for OAuth2 or SSO.
  • Implement account locking and password recovery features.

Contributing

Contributions are welcome! Feel free to submit a pull request or open an issue to discuss changes or enhancements.


Author

About

This project is a simple implementation of Role-Based Authentication using Spring Security. It demonstrates how to secure endpoints based on user roles and implement user authentication and authorization effectively.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages