Challenge - 5 Problems
Form Login Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2:00remaining
What happens when a user submits the login form with incorrect credentials?
Consider a Spring Boot application configured with form-based login. What is the typical behavior when a user submits the login form with wrong username or password?
Attempts:
2 left
💡 Hint
Think about how Spring Security handles authentication failures by default.
✗ Incorrect
Spring Security redirects users back to the login page and shows an error message when credentials are invalid.
📝 Syntax
intermediate2:00remaining
Which configuration snippet correctly enables form-based login in Spring Security?
Choose the correct Java configuration code to enable form-based login in a Spring Boot application using Spring Security.
Attempts:
2 left
💡 Hint
Remember the order: first define authorization, then enable form login.
✗ Incorrect
The correct pattern is to first configure authorization rules, then call formLogin() to enable form-based login.
❓ state_output
advanced2:00remaining
What is the value of the 'principal' object after successful form login?
After a user successfully logs in via form-based login, what does the 'principal' object in the SecurityContext typically contain?
Attempts:
2 left
💡 Hint
Think about what Spring Security stores to represent the logged-in user.
✗ Incorrect
Spring Security stores a UserDetails object as the principal after successful authentication.
🔧 Debug
advanced2:00remaining
Why does the custom login page not show after configuring formLogin().loginPage("/my-login")?
You configured form-based login with a custom login page URL '/my-login' but when accessing a protected page, the default login page still appears. What is the most likely cause?
Attempts:
2 left
💡 Hint
Check if the URL you set for loginPage() actually serves a page.
✗ Incorrect
If the custom login page URL is not handled by a controller or static resource, Spring Security falls back to the default login page.
🧠 Conceptual
expert3:00remaining
How does Spring Security handle CSRF protection with form-based login by default?
In a Spring Boot app with form-based login enabled, what is the default behavior of Spring Security regarding CSRF tokens?
Attempts:
2 left
💡 Hint
Think about security best practices for form submissions.
✗ Incorrect
Spring Security enables CSRF protection by default. The login form must include the CSRF token to prevent attacks.