SAML Assertion Consumer Service(ACS):設定並驗證回應端點
設定 ACS 公開 URL 與 binding,驗證回應目標與關聯,並排查 proxy 或多端點問題。
SAML Assertion Consumer Service(ACS):設定並驗證回應端點
SAML Assertion Consumer Service(ACS)是 Service Provider(SP)接收 Identity Provider(IdP)SAML Response 的協定端點。請在中繼資料登錄正確的公開 URL 與 binding,並在建立本機工作階段前驗證目的位址、bearer Recipient 和要求關聯。ACS 可公開存取,不代表收到的 XML 可以直接信任。
設定 ACS
在 SP 中繼資料的 SPSSODescriptor 下宣告 AssertionConsumerService,可包含 Location、Binding,以及用來選取多個端點的 index 或 isDefault。與 IdP 交換中繼資料並約定使用哪個端點。瀏覽器 SSO 常見 HTTP-POST,但雙方都必須支援並登錄該 binding。
使用符合實際外部 scheme、host、port、path 的公開 HTTPS URL。位於 reverse proxy 後方時,中繼資料應發布外部 URL,而非內部位址。
endpoint binding 必須與回應傳輸方式一致。
多個 ACS 時明確設定 default/index;要求中的 `AssertionConsumerServiceURL` 或 index 只能選取已登錄端點。
測試與正式環境的 URL 和 entity ID 應分開。
在 ACS 驗證回應
比對實際 HTTP URL 和中繼資料。若有 `Response.Destination`,依所選 profile 驗證。
使用預先設定的信任金鑰和 profile 規則驗證 IdP issuer 與 Response/Assertion 簽章。不要信任回應中任意附上的憑證。
bearer 模式要求 `SubjectConfirmationData.Recipient` 與接收回應的 ACS URL 一致,並在允許的時鐘誤差內檢查 `NotOnOrAfter`。
SP 發起的 SSO 要將 `InResponseTo` 與為該瀏覽器交易保存的 `AuthnRequest` 比對。IdP 發起的 unsolicited 回應依 profile 必須沒有 `InResponseTo`;額外風險和控制措施另行評估。
確認 audience 包含 SP entity ID。記錄已使用的 Response/Assertion ID,並拒絕重播。
驗證成功後才建立本機工作階段。依 IdP–SP 協議連結 NameID 與屬性;不要自動導向 XML 中任意 URL 或 `RelayState`。
| 現象 | 檢查項目 |
|---|---|
| IdP POST 時收到 404 | ACS Location、外部路徑 rewrite、HTTP-POST 等 binding |
| Recipient/Destination 不符 | 外部 HTTPS 與內部 HTTP URL、port/path、結尾斜線 |
| 選到非預期 ACS | index、isDefault、要求中的 ACS URL/index、快取的中繼資料 |
| 測試回應進入正式環境 | entity ID、憑證、endpoint 與 IdP 連線是否依環境區隔 |
| 重複回應被接受 | 所有應用程式執行個體共用的 Response/Assertion ID 防重播快取 |
不要為修正位址不符而停用 Recipient、audience 或簽章檢查。比對雙方實際傳送的 URL,並透過核准流程更新中繼資料。
在測試 IdP/SP 檢查 SP 發起登入、回應至未登錄 URL、Recipient 錯誤、回應過期、要求 ID 不符,以及 Response ID 重複。只有預期情況應建立工作階段;也要檢查 proxy/load balancer 後的公開 URL。這是驗證計畫,不代表已執行測試。不要記錄真實使用者 Assertion。
參考資料
[OASIS SAML V2.0 Profiles, §4.1 Web Browser SSO](https://docs.oasis-open.org/security/saml/v2.0/saml-profiles-2.0-os.pdf)
[OASIS SAML V2.0 Metadata](https://docs.oasis-open.org/security/saml/v2.0/saml-metadata-2.0-os.pdf)
[OASIS SAML V2.0 Core](https://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf)