QuizzesSpring Security Fundamentals
advanced
spring-boot
Spring Security Fundamentals
Test your understanding of authentication, authorisation, JWT, and Spring Security configuration.
30 minutes 8 questions Pass at 70%
Time Limit
30 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
8 questions on Spring Security Fundamentals. Work through them here, then start the quiz to answer them and see your score.
1.What is the difference between Authentication and Authorisation?
- AAuthentication verifies who you are; Authorisation determines what you can do
- BThey are the same concept, just different names
- CAuthentication checks permissions; Authorisation verifies identity
- DAuthentication is for APIs; Authorisation is for web pages
2.What does @PreAuthorize("hasRole('ADMIN')") do?
- AEncrypts the method's return value for ADMIN users only
- BLogs an audit event when an ADMIN calls the method
- CBlocks method execution if the current user does not have the ADMIN role
- DGrants ADMIN role to the current user
3.In a JWT-secured REST API, where is the token typically sent?
- AAuthorization: Bearer <token> request header
- BX-JWT-Token request header
- CAs a cookie named jwt
- DIn the request body as a "token" field
4.What is the SecurityContext in Spring Security?
- AThe class that stores all user credentials
- BA configuration class that defines security rules
- CThe database where user roles are stored
- DA thread-local holder that stores the current Authentication object for the duration of a request
5.What does BCryptPasswordEncoder do and why is it used?
- AEncrypts passwords symmetrically so they can be decrypted
- BHashes passwords with an adaptive salt to make brute-force attacks slow
- CConverts passwords to Base64 for safe storage
- DValidates password complexity rules
6.What is the role of OncePerRequestFilter in JWT authentication?
- AIt is a base class for a custom filter that runs exactly once per HTTP request to validate the JWT
- BIt ensures authentication is performed only on the first request in a session
- CIt caches the JWT to avoid re-parsing it on every request
- DIt rate-limits requests to once per user per second
7.What does permitAll() do in HttpSecurity configuration?
- AGrants all permissions to the ADMIN role
- BAllows access to the matched URL path without any authentication
- CDisables Spring Security for the entire application
- DAllows all HTTP methods on the matched path
8.What is CSRF and when should you disable it?
- ACross-Site Request Forgery — safe to disable for stateless REST APIs that use JWT (no cookies)
- BA Spring Security feature that logs all incoming requests
- CA session fixation prevention mechanism
- DCross-Site Resource Forgery — should never be disabled