Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to enable Spring Security auto-configuration in a Spring Boot application.
Spring Boot
@SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.[1](Application.class, args); } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'start' or 'launch' instead of 'run' causes compilation errors.
Forgetting to call any method to start the application.
✗ Incorrect
The SpringApplication.run() method starts the Spring Boot application and triggers auto-configuration including Spring Security.
2fill in blank
mediumComplete the code to add a dependency that triggers Spring Security auto-configuration in Maven's pom.xml.
Spring Boot
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-[1]</artifactId>
</dependency> Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'web' or 'data-jpa' does not enable security auto-configuration.
Forgetting to add the security starter dependency.
✗ Incorrect
Adding 'spring-boot-starter-security' dependency activates Spring Security auto-configuration.
3fill in blank
hardFix the error in the code to disable Spring Security auto-configuration in a Spring Boot test.
Spring Boot
@SpringBootTest( exclude = [1].class ) public class SecurityDisabledTest {}
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Excluding WebSecurityConfigurerAdapter does not disable auto-configuration.
Using EnableWebSecurity or SecurityFilterChain classes here is incorrect.
✗ Incorrect
To disable Spring Security auto-configuration, exclude SecurityAutoConfiguration.class.
4fill in blank
hardFill both blanks to customize HTTP security by disabling CSRF and permitting all requests.
Spring Boot
@Configuration @EnableWebSecurity public class SecurityConfig { @Bean public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { http.csrf().[1](); http.authorizeHttpRequests().anyRequest().[2](); return http.build(); } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using csrf().enable() instead of disable() causes errors.
Using authenticated() instead of permitAll() restricts access.
✗ Incorrect
Calling csrf().disable() turns off CSRF protection. permitAll() allows all requests without authentication.
5fill in blank
hardFill both blanks to create a password encoder bean using BCryptPasswordEncoder.
Spring Boot
@Configuration public class PasswordConfig { @Bean public [1] passwordEncoder() { return new [2](); } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using PasswordEncoderImpl which does not exist.
Returning SecurityConfig instead of a password encoder.
✗ Incorrect
The method returns a PasswordEncoder interface implemented by BCryptPasswordEncoder class instance.