使用 Sustainsys 和 Azure 的 SAML 单点注销给出 Message is invalid 错误
SAML Single Logout using Sustainsys and Azure giving Message is invalid error
详情:
我有一个使用 Azure AD 作为身份提供者的自定义服务提供者。我已经能够实现单点登录。尝试全局单点注销时会出现问题。我构建注销请求并按如下方式发送:
CommandResult commandResult = CommandFactory.GetCommand(CommandFactory.LogoutCommandName).Run(requestData, Options);
var responseWrapper = new HttpResponseWrapper(HttpResponse);
commandResult.ApplyCookies(responseWrapper);
commandResult.Apply(responseWrapper);
Azure 上弹出以下错误:
Sorry, but we’re having trouble signing you in.
AADSTS20012: An error occurred when we tried to process a
WS-Federation message. The message was invalid.
刷新页面后,Azure 说他们已成功将我注销。在服务提供商端,我看到带有签名和 x509 证书的初始注销请求。刷新后,Azure 将 SAML 注销请求(而不是注销响应)发送回 LogoutURL。
SAML 配置:
<sustainsys.saml2 entityId="serviceProviderURL.net"
publicOrigin="serviceProviderURL.net/Resource"
modulePath="/Saml2"
returnUrl="serviceProviderURL.net/homePage.aspx" authenticateRequestSigningBehavior="Never">
<identityProviders>
<add entityId="AzureProvidedID" signOnUrl="AzureProvidedURL/saml2" logoutUrl="https://login.microsoftonline.com/common/wsfederation?wa=wsignout1.0" allowUnsolicitedAuthnResponse="true" binding="HttpPost" wantAuthnRequestsSigned="false">
<signingCertificate fileName="~/Resources/Dev-Regression-SSO.cer" />
</add>
</identityProviders>
</sustainsys.saml2>
签名证书始终为空,除非我添加了服务证书。我为身份提供者添加服务证书,该身份提供者具有我从 Azure 获得的用于此 SSO 企业应用程序的签名证书。我还将服务提供商 .pfx 文件上传到同一个企业应用程序。
以下是我添加 pfx 和证书的代码。
try
{
var signingKeyPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
var X509Cert = new X509Certificate2(signingKeyPath + "\Dev-Regression-SSO.cer");
options.IdentityProviders.Default.SigningKeys.AddConfiguredKey(X509Cert);
}
catch (Exception ex)
{
CoreLogging.GeneralLogger.Error(String.Format(" Identity Provider Exception : {0}", ex.Message));
}
#endregion
#region Service Provider
try
{
var pp = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "Resources";
X509Certificate2 certificate1 = new X509Certificate2(pp + "\serviceProvider.pfx", "password", X509KeyStorageFlags.MachineKeySet);
options.SPOptions.ServiceCertificates.Add(certificate1);
}
catch(Exception ex)
{
CoreLogging.GeneralLogger.Error("Service Provider Exception : " + ex.Message);
}
我不确定我是否在正确的地方有正确的证书。我真的很感激任何意见。提前致谢。
沙拉德
我能够使用 Azure AD 进行全局单点注销。我需要确认两件事:
- 身份提供者的签名证书和服务提供者的服务证书。
- 注销 URL - Azure AD 将注销 URL 作为 https://login.microsoftonline.com/common/wsfederation?wa=wsignout1.0,这是不正确的。注销 URL 必须与 Azure 提供的登录URL 匹配。
详情:
我有一个使用 Azure AD 作为身份提供者的自定义服务提供者。我已经能够实现单点登录。尝试全局单点注销时会出现问题。我构建注销请求并按如下方式发送:
CommandResult commandResult = CommandFactory.GetCommand(CommandFactory.LogoutCommandName).Run(requestData, Options);
var responseWrapper = new HttpResponseWrapper(HttpResponse);
commandResult.ApplyCookies(responseWrapper);
commandResult.Apply(responseWrapper);
Azure 上弹出以下错误:
Sorry, but we’re having trouble signing you in.
AADSTS20012: An error occurred when we tried to process a WS-Federation message. The message was invalid.
刷新页面后,Azure 说他们已成功将我注销。在服务提供商端,我看到带有签名和 x509 证书的初始注销请求。刷新后,Azure 将 SAML 注销请求(而不是注销响应)发送回 LogoutURL。
SAML 配置:
<sustainsys.saml2 entityId="serviceProviderURL.net"
publicOrigin="serviceProviderURL.net/Resource"
modulePath="/Saml2"
returnUrl="serviceProviderURL.net/homePage.aspx" authenticateRequestSigningBehavior="Never">
<identityProviders>
<add entityId="AzureProvidedID" signOnUrl="AzureProvidedURL/saml2" logoutUrl="https://login.microsoftonline.com/common/wsfederation?wa=wsignout1.0" allowUnsolicitedAuthnResponse="true" binding="HttpPost" wantAuthnRequestsSigned="false">
<signingCertificate fileName="~/Resources/Dev-Regression-SSO.cer" />
</add>
</identityProviders>
</sustainsys.saml2>
签名证书始终为空,除非我添加了服务证书。我为身份提供者添加服务证书,该身份提供者具有我从 Azure 获得的用于此 SSO 企业应用程序的签名证书。我还将服务提供商 .pfx 文件上传到同一个企业应用程序。 以下是我添加 pfx 和证书的代码。
try
{
var signingKeyPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
var X509Cert = new X509Certificate2(signingKeyPath + "\Dev-Regression-SSO.cer");
options.IdentityProviders.Default.SigningKeys.AddConfiguredKey(X509Cert);
}
catch (Exception ex)
{
CoreLogging.GeneralLogger.Error(String.Format(" Identity Provider Exception : {0}", ex.Message));
}
#endregion
#region Service Provider
try
{
var pp = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "Resources";
X509Certificate2 certificate1 = new X509Certificate2(pp + "\serviceProvider.pfx", "password", X509KeyStorageFlags.MachineKeySet);
options.SPOptions.ServiceCertificates.Add(certificate1);
}
catch(Exception ex)
{
CoreLogging.GeneralLogger.Error("Service Provider Exception : " + ex.Message);
}
我不确定我是否在正确的地方有正确的证书。我真的很感激任何意见。提前致谢。 沙拉德
我能够使用 Azure AD 进行全局单点注销。我需要确认两件事:
- 身份提供者的签名证书和服务提供者的服务证书。
- 注销 URL - Azure AD 将注销 URL 作为 https://login.microsoftonline.com/common/wsfederation?wa=wsignout1.0,这是不正确的。注销 URL 必须与 Azure 提供的登录URL 匹配。