0
0
Spring Bootframework~10 mins

Form-based login configuration in Spring Boot - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to enable form-based login in Spring Security.

Spring Boot
http
  .authorizeHttpRequests(auth -> auth.anyRequest().authenticated())
  .[1]();
Drag options to blanks, or click blank then click option'
AhttpBasic
BformLogin
Ccsrf
Dlogout
Attempts:
3 left
💡 Hint
Common Mistakes
Using httpBasic() instead of formLogin()
Forgetting to call any login method
2fill in blank
medium

Complete the code to set a custom login page URL.

Spring Boot
http
  .formLogin(form -> form
    .loginPage("[1]")
  );
Drag options to blanks, or click blank then click option'
A/custom-login
B/logout
C/home
D/error
Attempts:
3 left
💡 Hint
Common Mistakes
Using the logout or error page URL instead of login page URL
Omitting the leading slash in the URL
3fill in blank
hard

Fix the error in configuring the login processing URL.

Spring Boot
http
  .formLogin(form -> form
    .loginProcessingUrl("[1]")
  );
Drag options to blanks, or click blank then click option'
A/process-login
Bprocess-login
C/login
Dlogin
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the leading slash in the URL
Using a URL that does not match the form action
4fill in blank
hard

Fill both blanks to configure a custom success and failure URL after login.

Spring Boot
http
  .formLogin(form -> form
    .defaultSuccessUrl("[1]")
    .failureUrl("[2]")
  );
Drag options to blanks, or click blank then click option'
A/dashboard
B/login-error
C/home
D/error
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up success and failure URLs
Using URLs that do not exist in the app
5fill in blank
hard

Fill all three blanks to configure form login with custom login page, success URL, and failure URL.

Spring Boot
http
  .formLogin(form -> form
    .loginPage("[1]")
    .defaultSuccessUrl("[2]")
    .failureUrl("[3]")
  );
Drag options to blanks, or click blank then click option'
A/user-login
B/welcome
C/login-failed
D/error
Attempts:
3 left
💡 Hint
Common Mistakes
Using URLs without leading slashes
Confusing success and failure URLs