Test and enhance your Spring Security expertise with this comprehensive quiz!
Each task challenges you to configure Spring Security for a specific use case, providing a hands-on approach to mastering real-world scenarios.
- 📚 Practical tasks for mastering Spring Security.
- 🛠️ Real-world use cases to boost your confidence.
- 💡 Opportunity to experiment with different configurations.
Configure a Spring Boot application with Spring Security to:
- Require username and password authentication for all endpoints.
- Use in-memory user details with roles
USER
andADMIN
.
Implement role-based access control:
USER
can access/user/**
.ADMIN
can access/admin/**
and/user/**
.- Restrict
/admin/**
to onlyADMIN
users.
- Create a custom login page to replace the default form-based login.
- Redirect users to different pages after login based on their roles.
- Integrate a password encoder (e.g.,
BCryptPasswordEncoder
) to hash and verify passwords stored in a database. - Use a database to manage user details instead of in-memory users.
- Use Spring Security's
SecurityContext
to pass user details into a service layer. - Create a custom user details service to load user data from a database.
- Configure the application to use JWT for authentication.
- Implement token generation and validation.
- Secure endpoints using JWT tokens.
Note: The solution uses the JJWT library, but you can explore other options like Auth0.
- Set up OAuth2 login with GitHub & Google as an identity provider.
- Allow users to log in using their GitHub accounts.
- Allow users to login using their Google sccounts
- Enable method-level security annotations.
- Use
@PreAuthorize
and@PostAuthorize
to secure specific methods in a service.
- Enable CSRF protection in the application.
- Configure CSRF tokens for form submissions.
- Configure the application to authenticate users against an LDAP server.
Feel free to fork the repository, enhance the solutions, or even add new tasks!
This project is inspired by the need to bridge the gap between learning concepts and applying them in real-world scenarios. Let's code securely!
Happy Learning! 🎉 And Don't forget to KISS 💋💋 (keep it simple stupid)