使用Spring Security SAML和SpringBoot在MetadataGeneratorFilter上设置entityBaseURL

时间:2018-04-29 21:20:37

标签: spring-boot spring-security spring-saml

我收到以下警告。如何设置entityBaseURL?

2018-04-19 19:38:00.771  WARN 31852 --- [http-nio-8080-exec-1] o.s.s.s.m.MetadataGeneratorFilter        : Generated default entity base URL https://test-auth.onlinephotosubmission.com:443 based on values in the first server request. Please set property entityBaseURL on MetadataGenerator bean bean to fixate the value.

1 个答案:

答案 0 :(得分:0)

application.properties中,添加以下设置

saml.sso.metadata-generator.entity-base-url=https://myserver.mydomain.com

在您的配置文件中(我的名字叫WebSecurityConfig),添加以下字段

@Value("${saml.sso.metadata-generator.entity-base-url}")
private String entityBaseUrl;

然后在同一配置文件中,通过调用entityBaseUrlMetadataGenerator bean上设置setEntityBaseURL()

@Bean
public MetadataGenerator metadataGenerator() {

    MetadataGenerator metadataGenerator = new MetadataGenerator();
    metadataGenerator.setEntityId(samlSpId);
    metadataGenerator.setExtendedMetadata(extendedMetadata());
    metadataGenerator.setIncludeDiscoveryExtension(false);
    metadataGenerator.setKeyManager(keyManager());
    metadataGenerator.setEntityBaseURL(entityBaseUrl);
    return metadataGenerator;
}