mirror of https://github.com/halo-dev/halo
Expose CryptoService and RateLimiterRegistry to plugins (#6638)
#### What type of PR is this? /kind feature /area core /area plugin /milestone 2.20.x #### What this PR does / why we need it: Currently, we are refactoring login and logout pages to make them extensible. If plugins want to realize a new authentication method, the CryptoService and RateLimiterRegistry may be used to authenticate. So this PR exposes the two beans to plugins. No side effect will be introduced. #### Does this PR introduce a user-facing change? ```release-note 【开发相关】允许在插件使用 CryptoService 和 RateLimiterRegistry ```pull/6647/head
parent
39545a1e4c
commit
a36822c861
|
@ -1,5 +1,6 @@
|
|||
package run.halo.app.plugin;
|
||||
|
||||
import io.github.resilience4j.ratelimiter.RateLimiterRegistry;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.GenericApplicationContext;
|
||||
|
@ -16,6 +17,7 @@ import run.halo.app.notification.NotificationCenter;
|
|||
import run.halo.app.notification.NotificationReasonEmitter;
|
||||
import run.halo.app.plugin.extensionpoint.ExtensionGetter;
|
||||
import run.halo.app.security.LoginHandlerEnhancer;
|
||||
import run.halo.app.security.authentication.CryptoService;
|
||||
|
||||
/**
|
||||
* Utility for creating shared application context.
|
||||
|
@ -69,6 +71,14 @@ public enum SharedApplicationContextFactory {
|
|||
);
|
||||
beanFactory.registerSingleton("extensionGetter",
|
||||
rootContext.getBean(ExtensionGetter.class));
|
||||
rootContext.getBeanProvider(CryptoService.class)
|
||||
.ifUnique(
|
||||
cryptoService -> beanFactory.registerSingleton("cryptoService", cryptoService)
|
||||
);
|
||||
rootContext.getBeanProvider(RateLimiterRegistry.class)
|
||||
.ifUnique(rateLimiterRegistry ->
|
||||
beanFactory.registerSingleton("rateLimiterRegistry", rateLimiterRegistry)
|
||||
);
|
||||
// TODO add more shared instance here
|
||||
|
||||
sharedContext.refresh();
|
||||
|
|
Loading…
Reference in New Issue