我使用WS-Federation和WS-Trust進行聯合身份驗證的產品。我相信你的情況是我們工作流程的一部分。
多年來,我開發了基於SOAP的API的PowerShell自動化,並且在某些時候我將這些知識整合到了庫中的WcfPS模塊中。
該模塊的code是開源的,雖然它的腳本在很大程度上依賴於來自System.ServiceModel
和System.IdentityModel
程序集的.net框架類和程序集。我提到這是因爲這些程序集中的大多數apis不能從.NET標準2中獲得,所以該模塊不幸的將不能用於非Windows操作系統。您還可以在我的帖子WCFPS - PowerShell module to work with SOAP endpoints中閱讀更多內容。
這是一個示例,您可以根據您的服務提供商要求和依賴方配置發佈對稱和承載令牌。該代碼需要對聯合安全流程,設置和術語有基本的瞭解。
# Define the ADFS MEX uri
$adfsMexUri="https://adfs.example.com/adfs/services/trust/mex"
#region Define authentication endpoints. One for windows and one with username/password
$windowsMixed13AuthenticationEndpoint="https://adfs.example.com/adfs/services/trust/13/windowsmixed"
$usernamePasswordMixed13AuthenticationEndpoint="https://adfs.example.com/adfs/services/trust/13/usernamemixed"
#endregion
#region Define service providers for which we want to issue a symmetric and a bearer token respectively
# Symmatric is for SOAP, WS-Trust
# Bearer is for Web, WS-Federation
$soapServiceProviderAppliesTo="https://myserviceprovider/Soap/"
$webServiceProviderAppliesTo="https://myserviceprovider/Web/"
#endregion
# Parse the MEX and locate the service endpoint
$issuerImporter=New-WcfWsdlImporter -Endpoint $adfsMexUri
#region Issue tokens with windows authentications
$issuerEndpoint=$issuerImporter | New-WcfServiceEndpoint -Endpoint $windowsMixed13AuthenticationEndpoint
$soapToken=New-SecurityToken -Endpoint $issuerEndpoint -AppliesTo $soapServiceProviderAppliesTo -Symmetric
$webToken=New-SecurityToken -Endpoint $issuerEndpoint -AppliesTo $webServiceProviderAppliesTo -Bearer
#endregion
#region Issue tokens with username/password credentials
$credential=Get-Credential
$issuerEndpoint=$issuerImporter | New-WcfServiceEndpoint -Endpoint $usernamePasswordMixed13AuthenticationEndpoint
$soapToken=New-SecurityToken -Endpoint $issuerEndpoint -Credential $credential -AppliesTo $soapServiceProviderAppliesTo -Symmetric
$webToken=New-SecurityToken -Endpoint $issuerEndpoint -Credential $credential -AppliesTo $webServiceProviderAppliesTo -Bearer
#endregion