【问题标题】:how to change the signature algorithm of SAML request in spring securityspring security中如何更改SAML请求的签名算法
【发布时间】:2014-07-04 02:02:34
【问题描述】:

我正在使用 spring security saml 扩展以 ADFS 作为 IDP 实现 SSO。

据我了解,spring security 使用 open saml 以 SHA1withRSA 作为签名算法对 SAML 请求进行签名。

我们需要更改以使用 SHA256withRSA 对 SAML 请求进行签名。

如何做到这一点?

感谢您对此提出的任何建议。提前非常感谢

【问题讨论】:

    标签: java spring digital-signature saml spring-saml


    【解决方案1】:

    确保使用最新的 Spring SAML(或至少将 OpenSAML 更新到最新版本)。如下扩展 SAMLBootstrap 类并将其插入 Spring 配置中而不是原始 SAMLBootstrap 类:

    package fi.schafer.saml.custom;
    
    import org.opensaml.Configuration;
    import org.opensaml.xml.security.BasicSecurityConfiguration;
    import org.opensaml.xml.signature.SignatureConstants;
    import org.springframework.beans.BeansException;
    import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
    
    public class SAMLBootstrap extends org.springframework.security.saml.SAMLBootstrap {
    
        public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    
            super.postProcessBeanFactory(beanFactory);
    
            BasicSecurityConfiguration config = (BasicSecurityConfiguration) Configuration.getGlobalSecurityConfiguration();
            config.registerSignatureAlgorithmURI("RSA", SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256);
            config.setSignatureReferenceDigestMethod(SignatureConstants.ALGO_ID_DIGEST_SHA256);
    
        }
    
    }
    

    【讨论】:

    • 是否可以使 registerSignatureAlgorithmURI 可配置?
    • 正在进行一个全新的实现,我不相信新功能会添加到当前版本中。
    • 我正在阅读您的答案@VladimírSchäfer 并且想知道我是否出于同样的原因收到错误stackoverflow.com/questions/68769788/…。我扩展了 SAMLBootstrap 类,但我仍然得到它。我不确定需要什么来改变摘要算法的安全强度。现在的强度是 160,应该大于 224。我是从调试中得到的。
    猜你喜欢
    • 2015-01-21
    • 2012-08-17
    • 1970-01-01
    • 2015-09-23
    • 2018-08-02
    • 2015-05-29
    • 1970-01-01
    • 1970-01-01
    • 2021-11-02
    相关资源
    最近更新 更多