liveBook · Manning

ReactiveUserDetailsService

As explained in Spring Security in Action, Second Edition

ReactiveUserDetailsService is a Spring Security contract that retrieves user details asynchronously for authentication in a reactive application.

ReactiveUserDetailsService is the Spring Security contract for retrieving a user by username in a reactive application. Its method returns Mono<UserDetails>, enabling asynchronous user lookup for authentication. A custom implementation can connect authentication to an application’s user store. section 17.2

public interface ReactiveUserDetailsService {
 Mono<UserDetails> findByUsername(String username);
}

The interface shows the contract directly: findByUsername accepts a username and returns Mono<UserDetails>. section 17.2

In-memory reactive users

A reactive application can register MapReactiveUserDetailsService as a bean, define user john with password 12345 and authority read, and provide a PasswordEncoder. Authentication can then protect /hello, with ReactiveAuthenticationManager using the service to find the user and the encoder to verify the password. section 17.2

How Spring Security in Action, Second Edition covers it

How deep it goes
Defines the Mono<UserDetails> contract and demonstrates an in-memory implementation, without detailing a custom persistent store.
Examples
Uses MapReactiveUserDetailsService with user john, authority read, and a protected /hello endpoint.
What it assumes
Assumes basic username-and-password authentication and reactive application concepts while paralleling UserDetailsService terminology.
What you can do after
Operate/configure reactive authentication with an in-memory user service or replace it with a custom implementation.
How it connects
Connects ReactiveAuthenticationManager with PasswordEncoder, SecurityContext, and reactive endpoint authorization.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring Security in Action, Second Edition. The section links point to the parts of the book it draws on.