有没有一种方法可以在基于Spring的应用程序中集成SAML2.0?我想实现我自己的SP,并与远程IdP通信。
发布于 2016-05-23 02:21:05
我最近为这个这里发布了一个春季启动插件。它基本上是Security的包装器,允许通过DSL或配置属性进行更友好的配置。下面是一个使用DSL的示例:
@SpringBootApplication
@EnableSAMLSSO
public class SpringBootSecuritySAMLDemoApplication {
public static void main(String[] args) {
SpringApplication.run(SpringBootSecuritySAMLDemoApplication.class, args);
}
@Configuration
public static class MvcConfig extends WebMvcConfigurerAdapter {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("index");
}
}
@Configuration
public static class MyServiceProviderConfig extends ServiceProviderConfigurerAdapter {
@Override
public void configure(ServiceProviderSecurityBuilder serviceProvider) throws Exception {
serviceProvider
.metadataGenerator()
.entityId("localhost-demo")
.and()
.sso()
.defaultSuccessURL("/home")
.idpSelectionPageURL("/idpselection")
.and()
.logout()
.defaultTargetURL("/")
.and()
.metadataManager()
.metadataLocations("classpath:/idp-ssocircle.xml")
.refreshCheckInterval(0)
.and()
.extendedMetadata()
.idpDiscoveryEnabled(true)
.and()
.keyManager()
.privateKeyDERLocation("classpath:/localhost.key.der")
.publicKeyPEMLocation("classpath:/localhost.cert");
}
}
}基本上这就是你所需要的所有代码。
发布于 2014-04-18 13:34:32
您必须使用XML完成所有SAML操作(惊喜,惊喜)。但其他的不应该妨碍,只是标准的弹性,布蒂的东西,例如。
@EnableAutoConfiguration
@Configuration
@ImportResource("my-crazy-ass-saml.xml")
public class Application implements WebMvcSecurityAdapter {
// set up security filter chain here
}发布于 2015-06-17 09:27:53
我尝试了@vdenotaris的解决方案,但似乎无法处理当前的spring-boot,因此放弃了这种方法。
因此,作为替代解决方案,我使用shibboleth使用apache中的mod_shib2模块执行所有SAML操作,并在上述apache实例后面使用mod_jk (也可以使用mod_proxy_ajp)运行tomcat。Tomcat接收所有所需的SAML属性作为请求属性,我只需将idp和用户id存储在常规用户表中,就可以将内部身份验证连接到外部(我需要SAML和基于密码的身份验证)。
https://stackoverflow.com/questions/23150126
复制相似问题