@Singleton
public class UrlWhitelistService
extends com.google.common.util.concurrent.AbstractIdleService
| Constructor and Description |
|---|
UrlWhitelistService(com.google.common.eventbus.EventBus eventBus,
ClusterConfigService clusterConfigService) |
| Modifier and Type | Method and Description |
|---|---|
void |
addEntry(WhitelistEntry entry) |
Optional<WhitelistEntry> |
getEntry(String id) |
UrlWhitelist |
getWhitelist()
Gets the whitelist by reading from the cluster configuration.
|
void |
handleWhitelistUpdated(ClusterConfigChangedEvent event) |
boolean |
isWhitelisted(String url) |
void |
removeEntry(String id) |
void |
saveWhitelist(UrlWhitelist whitelist) |
protected void |
shutDown() |
protected void |
startUp() |
addListener, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, executor, failureCause, isRunning, serviceName, startAsync, state, stopAsync, toString@Inject
public UrlWhitelistService(com.google.common.eventbus.EventBus eventBus,
ClusterConfigService clusterConfigService)
public UrlWhitelist getWhitelist()
There should always be a whitelist which is created by an initial migration but if there is none, we return a disabled one, which will consider all URLs as whitelisted.
This is because we can't easily guarantee that migrations are run before other services are started. On a system that didn't have a whitelist before, we have to add the URLs configured e.g. in lookup table data adapters to the whitelist by running a migration. If the services start before the migration has run, the configured URLs have to pass the whitelist though, otherwise the services won't be able to run properly. Once the migration has run, these URLs will have been added to whitelist and we are fine.
public void saveWhitelist(UrlWhitelist whitelist)
public boolean isWhitelisted(String url)
public Optional<WhitelistEntry> getEntry(String id)
public void addEntry(WhitelistEntry entry)
public void removeEntry(String id)
public void handleWhitelistUpdated(ClusterConfigChangedEvent event)
protected void startUp()
startUp in class com.google.common.util.concurrent.AbstractIdleServiceprotected void shutDown()
shutDown in class com.google.common.util.concurrent.AbstractIdleServiceCopyright © 2012–2021 Graylog, Inc.. All rights reserved.