QuizzesSpring Boot Security: Mastering Role-Based Access Control
intermediate
spring

Spring Boot Security: Mastering Role-Based Access Control

Test your knowledge on implementing role-based access control in Spring Boot applications.

18 minutes 12 questions Pass at 70%
Time Limit
18 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

12 questions on Spring Boot Security: Mastering Role-Based Access Control. Work through them here, then start the quiz to answer them and see your score.

  1. 1.In Spring Boot, which annotation is used to specify that a method requires a specific role?

    • A@PostAuthorize
    • B@PreAuthorize
    • C@RolesAllowed
    • D@Secured
  2. 2.Which of the following is a valid way to configure role-based access control in Spring Security?

    • AUsing XML configuration
    • BUsing JSON configuration
    • CUsing YAML configuration
    • DUsing Java configuration
  3. 3.What is the purpose of the @EnableGlobalMethodSecurity annotation in Spring Boot?

    • ATo enable global caching
    • BTo enable global exception handling
    • CTo enable global transaction management
    • DTo enable method-level security annotations
  4. 4.Which method in the WebSecurityConfigurerAdapter is typically overridden to configure role-based access?

    • Aconfigure(AuthenticationManagerBuilder auth)
    • Bconfigure(SecurityContext security)
    • Cconfigure(WebSecurity web)
    • Dconfigure(HttpSecurity http)
  5. 5.What is the default role prefix used by Spring Security when checking roles?

    • AUSER_
    • BROLE_
    • CADMIN_
    • DAUTH_
  6. 6.How can you specify multiple roles for a method using @PreAuthorize?

    • A@PreAuthorize("hasRoles('ROLE_USER', 'ROLE_ADMIN')")
    • B@PreAuthorize("hasAllRoles('ROLE_USER', 'ROLE_ADMIN')")
    • C@PreAuthorize("hasAnyRole('ROLE_USER', 'ROLE_ADMIN')")
    • D@PreAuthorize("hasRole('ROLE_USER, ROLE_ADMIN')")
  7. 7.Which annotation would you use to secure a REST endpoint to only allow access to users with the 'ADMIN' role?

    • A@Secured("ROLE_ADMIN")
    • B@PreAuthorize("hasRole('ADMIN')")
    • C@RolesAllowed("ADMIN")
    • D@PostAuthorize("hasRole('ADMIN')")
  8. 8.What is the function of the GrantedAuthority interface in Spring Security?

    • ATo handle authentication exceptions
    • BTo manage user sessions
    • CTo represent a user's role or authority
    • DTo configure security filters
  9. 9.In Spring Security, how can you customize the role prefix?

    • ABy using a custom GrantedAuthority implementation
    • BBy using the RoleHierarchy interface
    • CBy setting a property in application.properties
    • DBy overriding the configure method in WebSecurityConfigurerAdapter
  10. 10.Which of the following is NOT a method-level security annotation in Spring Security?

    • A@Secured
    • B@PreAuthorize
    • C@RolesAllowed
    • D@Authenticated
  11. 11.What is the role of the AuthenticationManager in Spring Security?

    • ATo configure security filters
    • BTo authenticate user credentials
    • CTo handle password encoding
    • DTo manage user sessions
  12. 12.How can you define a custom access decision manager in Spring Security?

    • ABy configuring a custom UserDetailsService
    • BBy extending the WebSecurityConfigurerAdapter class
    • CBy overriding the configure method in HttpSecurity
    • DBy implementing the AccessDecisionManager interface