How do you configure authentication and authorization in Spring Security?
Modern Spring Security setup: SecurityFilterChain, users, password encoding, URL and method authorization and JWT resource server.
Spread Your Knowledge. Questions with answers, tutorials and articles, newest first.
Modern Spring Security setup: SecurityFilterChain, users, password encoding, URL and method authorization and JWT resource server.
@SessionAttributes keeps a form object in the session across requests of one Spring MVC controller. See the multi-step form pattern and common pitfalls.
Set server.servlet.session.timeout, handle expired sessions with Spring Security 6 and override the timeout per session. Includes Spring Session and cookie settings.
HttpSession gives stateless HTTP a server-side memory per user. See how session IDs work, the key methods, timeouts and how to secure sessions.
Configure Spring Security sessions with creation policies, fixation protection, concurrent session limits and Spring Session for clustered applications.
Spring's @SessionScope creates one bean per HTTP session, ideal for per-user state like a shopping cart. See the proxy behaviour, examples and alternatives.
Manage user sessions in Spring with HttpSession, session scope, Boot cookie and timeout properties, Spring Security controls and Spring Session with Redis.
@EnableCaching switches on Spring's cache proxies so @Cacheable, @CachePut and @CacheEvict work. See providers, configuration and pitfalls such as self-invocation.
Learn how Spring builds cache keys by default and how to implement a custom KeyGenerator, apply it to @Cacheable and set it as the application default.
Ehcache stores the results of Spring @Cacheable methods in heap, off-heap or disk tiers. See the Spring Boot setup, a full example and alternatives.
Set up Spring caching with @EnableCaching and configure Caffeine, Redis, Ehcache 3 via JCache or the default provider in Spring Boot 3.
@CacheEvict removes entries from a Spring cache after data changes. See key-based and allEntries eviction, beforeInvocation and common pitfalls.
Use @CacheEvict, @CachePut and a TTL to keep Spring caches consistent with your data. Covers keys, allEntries, programmatic eviction and common pitfalls.
@CachePut updates a Spring cache every time a method runs, keeping reads fresh after writes. See examples, attributes and how it differs from @Cacheable.
Enable caching with @EnableCaching and declare a CacheManager bean. Examples cover in-memory, Caffeine, Redis and JCache or Ehcache 3 providers.
Spring rolls back only on unchecked exceptions by default. rollbackFor extends rollback to checked exceptions such as IOException.
Annotate Spring service classes or methods with @Transactional to run each business operation in one transaction. Covers rollback, propagation and pitfalls.
Propagation.REQUIRED, the default, joins an existing transaction or starts a new one, so related service calls commit or roll back together.
DataSourceTransactionManager provides local JDBC transactions for a single DataSource in Spring. See configuration, @Transactional use and its limits.
Choose and configure the right Spring PlatformTransactionManager for JDBC, JPA or JTA, and set up several managers for several databases.