This is a simple Spring Boot application demonstrating security using Spring Security.
- Configures password encoding using BCryptPasswordEncoder.
- Defines user details for authentication.
- Configures security filter chain for HTTP requests.
- Provides REST endpoints for login functionality.
- To access the login endpoints, use the following URLs:
- Admin endpoints:
- POST /login/admin - Saves an admin.
- GET /login/admin - Retrieves the admin.
- User endpoints:
- POST /login/user - Saves a user. Only Accessible by ADMIN role.
- GET /login/user - Retrieves the user.
- Admin endpoints:
- Users:
Username: Pheonix,Password: Pheonix123 (Role: USER)Username: Ninja,Password: Ninja987 (Roles: ADMIN, USER)
- CSRF protection is disabled.
- Users need to be logged in to access specific APIs.
- Authorization is enforced based on user roles.
To run this project locally, you need to have Java and Maven installed on your machine.
- Clone the repository
- Navigate to the project directory
- Update the port in
application.propertiesfile if required. - Run
mvn spring-boot:runto start the application - Access the resources at http://localhost:9000 like http://localhost:9000/login/admin, http://localhost:9000/login/user.
- Spring Boot
- Spring Boot Web
- Spring Boot Security
- Mayank Sahu (https://github.com/mayank19o7).