|
47 | 47 | import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
48 | 48 | import org.springframework.security.saml.*;
|
49 | 49 | import org.springframework.security.saml.context.SAMLContextProviderImpl;
|
| 50 | +import org.springframework.security.saml.context.SAMLContextProviderLB; |
50 | 51 | import org.springframework.security.saml.key.EmptyKeyManager;
|
51 | 52 | import org.springframework.security.saml.key.JKSKeyManager;
|
52 | 53 | import org.springframework.security.saml.key.KeyManager;
|
@@ -89,6 +90,11 @@ public class SAMLConfiguration {
|
89 | 90 | private static final String PROP_APP_ENTITY_ID = "proxy.saml.app-entity-id";
|
90 | 91 | private static final String PROP_BASE_URL = "proxy.saml.app-base-url";
|
91 | 92 | 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"; |
92 | 98 |
|
93 | 99 | @Inject
|
94 | 100 | private Environment environment;
|
@@ -281,6 +287,19 @@ public SAMLDefaultLogger samlLogger() {
|
281 | 287 |
|
282 | 288 | @Bean
|
283 | 289 | 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 | + } |
284 | 303 | return new SAMLContextProviderImpl();
|
285 | 304 | }
|
286 | 305 |
|
|
0 commit comments