mirror of https://github.com/halo-dev/halo
Expose user and role services into plugins (#6880)
#### What type of PR is this? /kind feature /area plugin /milestone 2.20.x #### What this PR does / why we need it: This PR exposes user and role services into plugins. Some authentication plugins may interact with users and users' roles. #### Does this PR introduce a user-facing change? ```release-note 允许在插件中使用 UserService 和 RoleService ```pull/6885/head
parent
c577deb6ee
commit
db4e68b732
|
@ -15,7 +15,7 @@ public class ValidationUtils {
|
||||||
public static final Pattern NAME_PATTERN = Pattern.compile(NAME_REGEX);
|
public static final Pattern NAME_PATTERN = Pattern.compile(NAME_REGEX);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A-Z, a-z, 0-9, !@#$%^&* are allowed.
|
* {@code A-Z, a-z, 0-9, !@#$%^&*} are allowed.
|
||||||
*/
|
*/
|
||||||
public static final String PASSWORD_REGEX = "^[A-Za-z0-9!@#$%^&*]+$";
|
public static final String PASSWORD_REGEX = "^[A-Za-z0-9!@#$%^&*]+$";
|
||||||
|
|
|
@ -8,6 +8,8 @@ import org.springframework.security.web.server.context.ServerSecurityContextRepo
|
||||||
import org.springframework.security.web.server.savedrequest.ServerRequestCache;
|
import org.springframework.security.web.server.savedrequest.ServerRequestCache;
|
||||||
import run.halo.app.content.PostContentService;
|
import run.halo.app.content.PostContentService;
|
||||||
import run.halo.app.core.extension.service.AttachmentService;
|
import run.halo.app.core.extension.service.AttachmentService;
|
||||||
|
import run.halo.app.core.user.service.RoleService;
|
||||||
|
import run.halo.app.core.user.service.UserService;
|
||||||
import run.halo.app.extension.DefaultSchemeManager;
|
import run.halo.app.extension.DefaultSchemeManager;
|
||||||
import run.halo.app.extension.ExtensionClient;
|
import run.halo.app.extension.ExtensionClient;
|
||||||
import run.halo.app.extension.ReactiveExtensionClient;
|
import run.halo.app.extension.ReactiveExtensionClient;
|
||||||
|
@ -86,6 +88,10 @@ public enum SharedApplicationContextFactory {
|
||||||
.ifUnique(serverRequestCache ->
|
.ifUnique(serverRequestCache ->
|
||||||
beanFactory.registerSingleton("serverRequestCache", serverRequestCache)
|
beanFactory.registerSingleton("serverRequestCache", serverRequestCache)
|
||||||
);
|
);
|
||||||
|
rootContext.getBeanProvider(UserService.class)
|
||||||
|
.ifUnique(userService -> beanFactory.registerSingleton("userService", userService));
|
||||||
|
rootContext.getBeanProvider(RoleService.class)
|
||||||
|
.ifUnique(roleService -> beanFactory.registerSingleton("roleService", roleService));
|
||||||
// TODO add more shared instance here
|
// TODO add more shared instance here
|
||||||
|
|
||||||
sharedContext.refresh();
|
sharedContext.refresh();
|
||||||
|
|
Loading…
Reference in New Issue