Skip to content

Commit 13c01c7

Browse files
committed
Merge pull request 'Add load balancer support for SAML authentication' (#40) from feature/saml_lb into develop
2 parents e0b4b8a + 0acff75 commit 13c01c7

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/main/java/eu/openanalytics/containerproxy/auth/impl/saml/SAMLConfiguration.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import org.springframework.security.core.userdetails.UsernameNotFoundException;
4848
import org.springframework.security.saml.*;
4949
import org.springframework.security.saml.context.SAMLContextProviderImpl;
50+
import org.springframework.security.saml.context.SAMLContextProviderLB;
5051
import org.springframework.security.saml.key.EmptyKeyManager;
5152
import org.springframework.security.saml.key.JKSKeyManager;
5253
import org.springframework.security.saml.key.KeyManager;
@@ -89,6 +90,11 @@ public class SAMLConfiguration {
8990
private static final String PROP_APP_ENTITY_ID = "proxy.saml.app-entity-id";
9091
private static final String PROP_BASE_URL = "proxy.saml.app-base-url";
9192
private static final String PROP_METADATA_URL = "proxy.saml.idp-metadata-url";
93+
private static final String PROP_LB_SERVER_NAME = "proxy.saml.lb-server-name";
94+
private static final String PROP_LB_CONTEXT_PATH = "proxy.saml.lb-context-path";
95+
private static final String PROP_LB_PORT_IN_URL = "proxy.saml.lb-port-in-url";
96+
private static final String PROP_LB_SCHEME = "proxy.saml.lb-scheme";
97+
private static final String PROP_LB_SERVER_PORT = "proxy.saml.lb-server-port";
9298

9399
@Inject
94100
private Environment environment;
@@ -281,6 +287,19 @@ public SAMLDefaultLogger samlLogger() {
281287

282288
@Bean
283289
public SAMLContextProviderImpl contextProvider() {
290+
String serverName = environment.getProperty(PROP_LB_SERVER_NAME);
291+
292+
if (serverName != null && !serverName.isEmpty()) {
293+
SAMLContextProviderLB lbProvider = new SAMLContextProviderLB();
294+
295+
lbProvider.setServerName(serverName);
296+
lbProvider.setContextPath(environment.getProperty(PROP_LB_CONTEXT_PATH, "/"));
297+
lbProvider.setIncludeServerPortInRequestURL(environment.getProperty(PROP_LB_PORT_IN_URL, Boolean.class, false));
298+
lbProvider.setScheme(environment.getProperty(PROP_LB_SCHEME, "https"));
299+
lbProvider.setServerPort(environment.getProperty(PROP_LB_SERVER_PORT, Integer.class, 443));
300+
301+
return lbProvider;
302+
}
284303
return new SAMLContextProviderImpl();
285304
}
286305

0 commit comments

Comments
 (0)