Expose ReactiveUserDetailsService to authentication plugins (#6885)

#### What type of PR is this?

/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

This PR exposes ReactiveUserDetailsService to authentication plugins.

#### Does this PR introduce a user-facing change?

```release-note
支持在插件中使用 ReactiveUserDetailsService
```
pull/6889/head
John Niang 2024-10-17 10:43:30 +08:00 committed by GitHub
parent 8df91e80b3
commit 02def4e20a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import io.github.resilience4j.ratelimiter.RateLimiterRegistry;
import org.springframework.cache.CacheManager;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.security.core.userdetails.ReactiveUserDetailsService;
import org.springframework.security.web.server.context.ServerSecurityContextRepository;
import org.springframework.security.web.server.savedrequest.ServerRequestCache;
import run.halo.app.content.PostContentService;
@ -92,6 +93,10 @@ public enum SharedApplicationContextFactory {
.ifUnique(userService -> beanFactory.registerSingleton("userService", userService));
rootContext.getBeanProvider(RoleService.class)
.ifUnique(roleService -> beanFactory.registerSingleton("roleService", roleService));
rootContext.getBeanProvider(ReactiveUserDetailsService.class)
.ifUnique(userDetailsService ->
beanFactory.registerSingleton("userDetailsService", userDetailsService)
);
// TODO add more shared instance here
sharedContext.refresh();