Interface AlhUserIdResolver
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Strategy for extracting the current user id to populate
AlhMdcKeys.USER_ID.
Provide a @Bean AlhUserIdResolver to override the default behavior.
The default implementation returns "anonymous" for every request — apps that
use Spring Security typically want to plug in something like:
@Bean
AlhUserIdResolver alhUserIdResolver() {
return req -> {
var auth = SecurityContextHolder.getContext().getAuthentication();
if (auth != null && auth.getPrincipal() instanceof Long userId) {
return String.valueOf(userId);
}
return "anonymous";
};
}
-
Method Summary
-
Method Details
-
resolve
-