-
Notifications
You must be signed in to change notification settings - Fork 24.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hot-reloadable remote cluster credentials (with blocking call fix) (#…
…103215) Brings back #102798, with a tweak to avoid tripping on a blocking operation. Only change compared to the original PR is 4072fac
- Loading branch information
Showing
25 changed files
with
1,069 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pr: 102798 | ||
summary: Hot-reloadable remote cluster credentials | ||
area: Security | ||
type: enhancement | ||
issues: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
server/src/main/java/org/elasticsearch/transport/RemoteClusterCredentialsManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.transport; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.elasticsearch.common.Strings; | ||
import org.elasticsearch.common.settings.SecureString; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.core.Nullable; | ||
|
||
import java.util.Map; | ||
|
||
import static org.elasticsearch.transport.RemoteClusterService.REMOTE_CLUSTER_CREDENTIALS; | ||
|
||
public class RemoteClusterCredentialsManager { | ||
|
||
private static final Logger logger = LogManager.getLogger(RemoteClusterCredentialsManager.class); | ||
|
||
private volatile Map<String, SecureString> clusterCredentials; | ||
|
||
public RemoteClusterCredentialsManager(Settings settings) { | ||
updateClusterCredentials(settings); | ||
} | ||
|
||
public void updateClusterCredentials(Settings settings) { | ||
clusterCredentials = REMOTE_CLUSTER_CREDENTIALS.getAsMap(settings); | ||
logger.debug( | ||
() -> Strings.format( | ||
"Updated remote cluster credentials for clusters: [%s]", | ||
Strings.collectionToCommaDelimitedString(clusterCredentials.keySet()) | ||
) | ||
); | ||
} | ||
|
||
@Nullable | ||
public SecureString resolveCredentials(String clusterAlias) { | ||
return clusterCredentials.get(clusterAlias); | ||
} | ||
|
||
public boolean hasCredentials(String clusterAlias) { | ||
return clusterCredentials.containsKey(clusterAlias); | ||
} | ||
|
||
public static final RemoteClusterCredentialsManager EMPTY = new RemoteClusterCredentialsManager(Settings.EMPTY); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.