Complete the code to enable form-based login in Spring Security.
http
.authorizeHttpRequests(auth -> auth.anyRequest().authenticated())
.[1]();The formLogin() method enables form-based login in Spring Security.
Complete the code to set a custom login page URL.
http
.formLogin(form -> form
.loginPage("[1]")
);The loginPage() method sets the URL for the custom login page.
Fix the error in configuring the login processing URL.
http
.formLogin(form -> form
.loginProcessingUrl("[1]")
);The loginProcessingUrl() requires a URL starting with a slash to correctly map the login form submission.
Fill both blanks to configure a custom success and failure URL after login.
http
.formLogin(form -> form
.defaultSuccessUrl("[1]")
.failureUrl("[2]")
);defaultSuccessUrl() sets where to go after successful login, and failureUrl() sets where to go after failure.
Fill all three blanks to configure form login with custom login page, success URL, and failure URL.
http
.formLogin(form -> form
.loginPage("[1]")
.defaultSuccessUrl("[2]")
.failureUrl("[3]")
);This configures a custom login page at /user-login, redirects to /welcome on success, and to /login-failed on failure.