簡體   English   中英

如何啟用 SAML2 AuthNRequest 簽名

[英]How to enable signing of SAML2 AuthNRequest

我們有一個 spring 啟動應用程序,其中配置了用於身份驗證的 Saml2。

我們很難配置 Saml2 AuthNRequest 的簽名,由於這個原因在 IDP 被拒絕(這是 ADFS,真的不知道它的版本)。 我們試圖禁用簽名要求,並且我們的應用程序運行良好。 但是,進行此禁用只是為了測試我們是否已准備就緒。

現在所缺少的只是 AuthNRequest 的簽名。 這個鏈接似乎有同樣的問題: Spring Security SAML: Getting <Signature> block to appear in <AuthnRequest> 它的解決方案似乎是創建WebSSOProfileOptions並將綁定設置為SAMLConstants.SAML2_POST_BINDING_URI

但是似乎存在某種版本不匹配之類的。 我們根本無法從我們的類路徑中找到這個 WebSSPProfileOptions class。 我對這一切都很陌生,包括 gradle,但我們的 gradle 將其作為依賴項,如下所示:

+--- org.springframework.security:spring-security-saml2-service-provider -> 5.4.7
|    +--- org.opensaml:opensaml-core:3.4.6

我真的希望有一種方法可以在配置中說明,簽名是在 AuthNRequest 消息上完成的。

spring:
  security:
    saml2:
      relyingparty:
        registration:
          my-sp:
            decryption.credentials:
              - private-key-location: "classpath:credentials/my_private_key" 
                certificate-location: "classpath:credentials/my_cert"
            signing.credentials:
              - private-key-location: "classpath:credentials/my_private_key"
                certificate-location: "classpath:credentials/my_cert"
            identityprovider:
              entity-id: http://idp.....
              verification.credentials:
                  - certificate-location: "classpath:credentials/idp......crt"
              singlesignon:
                sign-request: true
                url: https://idp......
              metadata-uri: https://.....

如果不能通過配置強制執行 AuthnRequest 的簽名,那么正確的做法是什么。

降級以將此 WebSSPProfileOptions 放入類路徑感覺有點苛刻。 spring-security-saml2-core-1.0.10.RELEASE.jar 似乎有它。 Web 頁https://spring.io/projects/spring-security-saml說它正在被https://docs.spring.io/spring-security/site/docs/5.2.1.RELEASE/reference/取代htmlsingle/#saml2

簡而言之,我們如何使用 spring-security-saml2-service-provider 版本 5.4.7 強制簽署 AuthnRequest

我會回答我自己的問題,因為我認為我們已經解決了。 可能還有一種方法可以強制在 spring 上簽名,這正是我最初的問題所在。

問題是,spring 的實現似乎在尋找WantAuthnRequestsSigned="true" ,而它在我們的 IDP 元數據中丟失了。

  <EntityDescriptor xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
        entityID="http://idp......">
    <IDPSSODescriptor xmlns:ds="http://www.w3.org/2000/09/xmldsig#" 
        protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol"
        WantAuthnRequestsSigned="true">

我們設法解決了這個問題,方法是下載 IDP 元數據,添加上述屬性並將固定元數據存儲在 spring 可訪問的位置。這不是一個完美的解決方案,但這是我們目前能做的最好的。

基於這一發現,我認為 IDP 或 spring 代碼中存在錯誤。 如果默認值為“true”,則錯誤為 spring。如果為“false”,則錯誤在 IDP 中。 如果未指定默認行為,那么每個人都會倒霉。

如果我發現更多關於這個主題的信息,我會在這里更新。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM