Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose CryptoService and RateLimiterRegistry to plugins #6638

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -16,6 +17,7 @@
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.
Expand Down Expand Up @@ -69,6 +71,14 @@ public static ApplicationContext create(ApplicationContext rootContext) {
);
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();
Expand Down
Loading