1

我想为基于 spring 的应用程序使用注释配置。SSO 还需要 SAML2.0 消化和生成。

注解配置仅受 Spring 4.0 和 Spring security 3.2.4 支持

Spring security SAML 1.0 的集成是否可行?

更新:Vladimír Schäfer 提供的示例项目确实很有帮助。

但是在sso登录之后,页面已经被重定向到服务提供商应用程序上的认证失败URL。

SAML 响应如下:

 <samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
            Destination="http://myIP:8080/websso/saml/SSO"
            ID="s237fe42260c297d9dfd7845b3691ef76e0bc27c76"
            InResponseTo="a14hc23eda9j396g2h5aff4076216g5"
            IssueInstant="2014-08-28T07:36:07Z"
            Version="2.0"
            >
    <saml:Issuer xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">http://idp.ssocircle.com</saml:Issuer>
    <samlp:Status xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">
            <samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"
                              xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
                              />
    </samlp:Status>
    <saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
                    ID="s2e84d407027285a27d32a70c93ebdc70298956c8d"
                    IssueInstant="2014-08-28T07:36:07Z"
                    Version="2.0"
                    >
            <saml:Issuer>http://idp.ssocircle.com</saml:Issuer>
            <saml:Subject>
                    <saml:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
                                 NameQualifier="http://idp.ssocircle.com"
                                 >nameID</saml:NameID>
                    <saml:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
                            <saml:SubjectConfirmationData InResponseTo="a14hc23eda9j396g2h5aff4076216g5"
                                                          NotOnOrAfter="2014-08-28T07:46:07Z"
                                                          Recipient="http://myIP:8080/websso/saml/SSO"
                                                          />
                    </saml:SubjectConfirmation>
            </saml:Subject>
            <saml:Conditions NotBefore="2014-08-28T07:26:07Z"
                             NotOnOrAfter="2014-08-28T07:46:07Z"
                             >
                    <saml:AudienceRestriction>
                            <saml:Audience>entityID</saml:Audience>
                    </saml:AudienceRestriction>
            </saml:Conditions>
            <saml:AuthnStatement AuthnInstant="2014-08-28T07:35:44Z"
                                 SessionIndex="s274ab5c8a81ed49654745a6583214314f65138201"
                                 >
                    <saml:AuthnContext>
                            <saml:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</saml:AuthnContextClassRef>
                    </saml:AuthnContext>
            </saml:AuthnStatement>
    </saml:Assertion>
   </samlp:Response>

我怀疑这是由于 SP 的时区与 IDP 不同,我该如何跳过这个?

4

2 回答 2

2

Spring SAML 似乎适用于 Spring 4.0 和 Spring Security 3.2.4。您可以使用spring-boot-security-saml-sample项目作为参考。

Spring SAML 的下一个版本很可能包含对 Java 配置的额外支持,但正如上面的示例所示,可以让项目的所有内容都按原样工作。

于 2014-08-21T13:18:31.200 回答
0

签出这个答案:它基本上描述了我最近发布的一个插件,它允许您以这种方式配置 Spring Boot 和 Spring Security SAML:

@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");

        }
    }
}
于 2016-05-23T02:35:00.953 回答