Skip to content

Feature/proxy auth #578

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

Open
wants to merge 42 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
5130220
Merge pull request #546 from splitio/development
chillaq Apr 17, 2025
193f3c4
Merge pull request #571 from splitio/development
chillaq May 29, 2025
2bc5767
Updated SplitClientConfig
chillaq Jun 24, 2025
3cca5ea
Added proxy scheme
chillaq Jun 25, 2025
0267513
Update factory
chillaq Jun 25, 2025
436dc2a
Added proxy tests
chillaq Jun 25, 2025
b42fddc
updated test
chillaq Jun 26, 2025
74a4533
Merge pull request #574 from splitio/FME-4283-proxy-auth-config
chillaq Jun 30, 2025
80b8f35
Merge pull request #575 from splitio/FME-4285-proxy-auth-factory
chillaq Jun 30, 2025
d2bdc02
Added sslcontext to SSE
chillaq Jun 30, 2025
c4c2eea
Merge pull request #576 from splitio/proxy-auth-sse
chillaq Jun 30, 2025
0489c0d
Added auto refresh proxy token
chillaq Jun 30, 2025
4a86a3d
disable test
chillaq Jun 30, 2025
a5a92f8
disabled test
chillaq Jun 30, 2025
32f5a11
disabled test
chillaq Jun 30, 2025
853bd7b
Merge pull request #577 from splitio/proxy-auth-auto-refresh-token
chillaq Jun 30, 2025
ce3aec5
renamed interface
chillaq Jun 30, 2025
f62acd9
Merge branch 'development' into feature/proxy-auth
chillaq Jun 30, 2025
4662ee7
Fixed config property and test
chillaq Jul 1, 2025
61fe715
Rename config field
chillaq Jul 1, 2025
eef3227
Merge pull request #579 from splitio/proxy-auth-fix
chillaq Jul 1, 2025
e53c5d0
polishing
chillaq Jul 1, 2025
21d43be
polish
chillaq Jul 1, 2025
d9e2bce
polish
chillaq Jul 1, 2025
2113b7c
polish
chillaq Jul 1, 2025
a5e4dc1
Added new proxy config params
chillaq Jul 16, 2025
741e23d
revert version back
chillaq Jul 16, 2025
9c11e85
Updated pom and proxy config
chillaq Jul 17, 2025
dfd9cfc
removed empty element
chillaq Jul 17, 2025
b127c0e
Update ci.yml
chillaq Jul 17, 2025
264f084
Update SDK version to rc3
chillaq Jul 17, 2025
1a25ace
Merge branch 'FME-7183-update-proxy-config' of https://github.com/spl…
chillaq Jul 17, 2025
d30ef5a
Update client/src/main/java/io/split/client/dtos/ProxyConfiguration.java
chillaq Jul 17, 2025
9bb8b29
Added check for missing url
chillaq Jul 17, 2025
0f39dec
Merge branch 'FME-7183-update-proxy-config' of https://github.com/spl…
chillaq Jul 17, 2025
bdad865
polishing
chillaq Jul 17, 2025
a32fd58
Merge pull request #586 from splitio/FME-7183-update-proxy-config
chillaq Jul 17, 2025
f952109
polishing
chillaq Jul 18, 2025
392d663
polishing
chillaq Jul 18, 2025
e228e1d
polish
chillaq Jul 18, 2025
77c681a
polishing
chillaq Jul 18, 2025
88d7a56
Merge pull request #587 from splitio/proxy-polish
chillaq Jul 23, 2025
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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ jobs:
if: matrix.jdk == '8' && github.event_name == 'pull_request' && github.ref != 'refs/heads/master' && github.ref != 'refs/heads/development'
run: mvn checkstyle::check

- name: Deploy
if: matrix.jdk == '8' && github.event_name == 'push' && github.ref != 'refs/heads/master' && github.ref != 'refs/heads/development'
run: mvn --batch-mode deploy -P test
# - name: Deploy
# if: matrix.jdk == '8' && github.event_name == 'push' && github.ref != 'refs/heads/master' && github.ref != 'refs/heads/development'
# run: mvn --batch-mode deploy -P test

- name: SonarQube Scan (Push)
if: matrix.jdk == '11' && github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/development')
Expand Down
6 changes: 3 additions & 3 deletions client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<parent>
<groupId>io.split.client</groupId>
<artifactId>java-client-parent</artifactId>
<version>4.16.0</version>
<version>4.17.0-rc3</version>
</parent>
<version>4.16.0</version>
<version>4.17.0-rc3</version>
<artifactId>java-client</artifactId>
<packaging>jar</packaging>
<name>Java Client</name>
Expand All @@ -24,7 +24,7 @@
<version>0.8.0</version>
<extensions>true</extensions>
<configuration>
<ignorePublishedComponents>true</ignorePublishedComponents>
<ignorePublishedComponents>false</ignorePublishedComponents>
<publishingServerId>central</publishingServerId>
<autoPublish>false</autoPublish>
<waitUntil>published</waitUntil>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package io.split.client;

import io.split.client.dtos.BearerCredentialsProvider;
import org.apache.hc.client5.http.auth.AuthScope;
import org.apache.hc.client5.http.auth.BearerToken;
import org.apache.hc.client5.http.auth.Credentials;
import org.apache.hc.core5.http.protocol.HttpContext;

class HttpClientDynamicCredentials implements org.apache.hc.client5.http.auth.CredentialsProvider {

private final BearerCredentialsProvider _bearerCredentialsProvider;

public HttpClientDynamicCredentials (BearerCredentialsProvider bearerCredentialsProvider) {
_bearerCredentialsProvider = bearerCredentialsProvider;
}

@Override
public Credentials getCredentials(AuthScope authScope, HttpContext context) {

// This Provider is invoked every time a request is made.
// This should invoke a user-custom provider responsible for:
return new BearerToken(_bearerCredentialsProvider.getToken());
}

}

69 changes: 67 additions & 2 deletions client/src/main/java/io/split/client/SplitClientConfig.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.split.client;

import io.split.client.dtos.ProxyConfiguration;
import io.split.client.impressions.ImpressionListener;
import io.split.client.impressions.ImpressionsManager;
import io.split.client.utils.FileTypeEnum;
Expand All @@ -8,6 +9,7 @@
import io.split.storages.enums.OperationMode;
import io.split.storages.enums.StorageMode;
import org.apache.hc.core5.http.HttpHost;
import org.slf4j.LoggerFactory;
import pluggable.CustomStorageWrapper;

import java.io.IOException;
Expand All @@ -27,13 +29,22 @@
*/
public class SplitClientConfig {

private static final org.slf4j.Logger _log = LoggerFactory.getLogger(SplitClientConfig.class);
public static final String LOCALHOST_DEFAULT_FILE = "split.yaml";
public static final String SDK_ENDPOINT = "https://sdk.split.io";
public static final String EVENTS_ENDPOINT = "https://events.split.io";
public static final String AUTH_ENDPOINT = "https://auth.split.io/api/v2/auth";
public static final String STREAMING_ENDPOINT = "https://streaming.split.io/sse";
public static final String TELEMETRY_ENDPOINT = "https://telemetry.split.io/api/v1";

public static class HttpScheme {
private HttpScheme() {
throw new IllegalStateException("Utility class");
}
public static final String HTTP = "http";
public static final String HTTPS = "https";
}

private final String _endpoint;
private final String _eventsEndpoint;

Expand Down Expand Up @@ -82,6 +93,7 @@ public class SplitClientConfig {
private final ThreadFactory _threadFactory;

// Proxy configs
private final ProxyConfiguration _proxyConfiguration;
private final HttpHost _proxy;
private final String _proxyUsername;
private final String _proxyPassword;
Expand Down Expand Up @@ -118,6 +130,7 @@ private SplitClientConfig(String endpoint,
HttpHost proxy,
String proxyUsername,
String proxyPassword,
ProxyConfiguration proxyConfiguration,
int eventsQueueSize,
long eventSendIntervalInMillis,
int maxStringLength,
Expand Down Expand Up @@ -171,6 +184,7 @@ private SplitClientConfig(String endpoint,
_proxy = proxy;
_proxyUsername = proxyUsername;
_proxyPassword = proxyPassword;
_proxyConfiguration = proxyConfiguration;
_eventsQueueSize = eventsQueueSize;
_eventSendIntervalInMillis = eventSendIntervalInMillis;
_maxStringLength = maxStringLength;
Expand Down Expand Up @@ -302,6 +316,10 @@ public String proxyPassword() {
return _proxyPassword;
}

public ProxyConfiguration proxyConfiguration() {
return _proxyConfiguration;
}

public long eventSendIntervalInMillis() {
return _eventSendIntervalInMillis;
}
Expand Down Expand Up @@ -417,8 +435,8 @@ public boolean isSdkEndpointOverridden() {
}

public CustomHttpModule alternativeHTTPModule() { return _alternativeHTTPModule; }
public static final class Builder {

public static final class Builder {
private String _endpoint = SDK_ENDPOINT;
private boolean _endpointSet = false;
private String _eventsEndpoint = EVENTS_ENDPOINT;
Expand All @@ -442,6 +460,7 @@ public static final class Builder {
private int _proxyPort = -1;
private String _proxyUsername;
private String _proxyPassword;
private ProxyConfiguration _proxyConfiguration;
private int _eventsQueueSize = 500;
private long _eventSendIntervalInMillis = 30 * (long)1000;
private int _maxStringLength = 250;
Expand Down Expand Up @@ -734,32 +753,44 @@ public Builder waitBeforeShutdown(int waitTime) {

/**
* The host location of the proxy. Default is localhost.
* @deprecated
* This method is deprecated.
* <p> Use {@link ProxyConfiguration)} instead.
*
* @param proxyHost location of the proxy
* @return this builder
*/
@Deprecated
public Builder proxyHost(String proxyHost) {
_proxyHost = proxyHost;
return this;
}

/**
* The port of the proxy. Default is -1.
* @deprecated
* This method is deprecated.
* <p> Use {@link ProxyConfiguration)} instead.
*
* @param proxyPort port for the proxy
* @return this builder
*/
@Deprecated
public Builder proxyPort(int proxyPort) {
_proxyPort = proxyPort;
return this;
}

/**
* Set the username for authentication against the proxy (if proxy settings are enabled). (Optional).
* @deprecated
* This method is deprecated.
* <p> Use {@link ProxyConfiguration)} instead.
*
* @param proxyUsername
* @return this builder
*/
@Deprecated
public Builder proxyUsername(String proxyUsername) {
_proxyUsername = proxyUsername;
return this;
Expand All @@ -776,6 +807,17 @@ public Builder proxyPassword(String proxyPassword) {
return this;
}

/**
* Set the mtls authentication against the proxy (if proxy settings are enabled). (Optional).
*
* @param proxyConfiguration
* @return this builder
*/
public Builder proxyConfiguration(ProxyConfiguration proxyConfiguration) {
_proxyConfiguration = proxyConfiguration;
return this;
}

/**
* Disables running destroy() on shutdown by default.
*
Expand Down Expand Up @@ -927,7 +969,7 @@ public Builder operationMode(OperationMode mode) {

/**
*
* @param storage mode
* @param mode
* @return this builder
*/
public Builder storageMode(StorageMode mode) {
Expand Down Expand Up @@ -1096,6 +1138,26 @@ private void verifyAlternativeClient() {
}
}

private void verifyProxy() {
if (_proxyConfiguration == null)
return;

if (_proxyPort != -1) {
_log.warn("Both the deprecated proxy configuration methods (`proxyHost`, `proxyPort`, `proxyUsername`, or `proxyPassword`) " +
"and the new `ProxyConfiguration` builder are being used. `ProxyConfiguration` will take precedence.");
}

if (!(_proxyConfiguration.getHost().getSchemeName().equals(HttpScheme.HTTP) ||
_proxyConfiguration.getHost().getSchemeName().equals(HttpScheme.HTTPS))) {
throw new IllegalArgumentException("Proxy scheme must be either http or https.");
}

if ((_proxyConfiguration.getP12File() != null && _proxyConfiguration.getPassKey() == null) ||
(_proxyConfiguration.getP12File() == null && _proxyConfiguration.getPassKey() != null)) {
throw new IllegalArgumentException("Proxy mTLS must have p12 file path and name, and pass phrase.");
}
}

public SplitClientConfig build() {

verifyRates();
Expand All @@ -1108,6 +1170,8 @@ public SplitClientConfig build() {

verifyAlternativeClient();

verifyProxy();

if (_numThreadsForSegmentFetch <= 0) {
throw new IllegalArgumentException("Number of threads for fetching segments MUST be greater than zero");
}
Expand All @@ -1133,6 +1197,7 @@ public SplitClientConfig build() {
proxy(),
_proxyUsername,
_proxyPassword,
_proxyConfiguration,
_eventsQueueSize,
_eventSendIntervalInMillis,
_maxStringLength,
Expand Down
Loading