gpt4 book ai didi

asp.net-core - 无法使用 Sustainsys 的 Saml2 注销

转载 作者:行者123 更新时间:2023-12-04 10:58:55 26 4
gpt4 key购买 nike

这应该将我的应用程序重定向到我的 AdFs 注销页面,然后将我重定向回我的应用程序。
但是,它只是将我重定向到我的路由“/logout”。
在我的 ADFS 服务器上查看日志没有任何 react 。

        [AllowAnonymous]
[HttpGet]
[Route("api/logout")]
public async Task<IActionResult> Logout()
{
return SignOut(new AuthenticationProperties()
{
RedirectUri = "/logout"
},
Saml2Defaults.Scheme);
}


登录工作正常。我什至尝试过同样的方法,但不起作用。这里,ReturnUrl 方法从 HttpContext.Response.Header 获取位置。当我尝试注销时,该位置始终为空。
        [AllowAnonymous]
[HttpGet]
[Route("api/login")]
public async Task<string> LoginAdfs()
{

string redirectUri = _appSettings.Saml.SpEntityId;

await HttpContext.ChallengeAsync(new AuthenticationProperties
{
RedirectUri = string.Concat(redirectUri, "/autenticado")
});
return ReturnUrl();
}

知道会发生什么吗?

更新 21/11/2019

结果是 Saml2Handler 根本没有尝试将请求发送到服务器。我在输出窗口收到这些消息:
Sustainsys.Saml2.AspNetCore2.Saml2Handler: Debug: Initiating logout, checking requirements for federated logout
Issuer of LogoutNameIdentifier claim (should be Idp entity id):
Issuer is a known Idp: False
Session index claim (should have a value):
Idp has SingleLogoutServiceUrl:
There is a signingCertificate in SPOptions: True
Idp configured to DisableOutboundLogoutRequests (should be false):
Sustainsys.Saml2.AspNetCore2.Saml2Handler: Information: Federated logout not possible, redirecting to post-logout

这是我的启动配置,我不明白这里有什么问题:
            ServiceCertificate se = new ServiceCertificate()
{
Certificate = new X509Certificate2(SpCert, "",X509KeyStorageFlags.MachineKeySet),
Use = CertificateUse.Signing
};

SPOptions sp = new SPOptions
{
AuthenticateRequestSigningBehavior = SigningBehavior.Never,
EntityId = new EntityId(SpEntityId),
ReturnUrl = new Uri("/login"),
NameIdPolicy = new Sustainsys.Saml2.Saml2P.Saml2NameIdPolicy(null, Sustainsys.Saml2.Saml2P.NameIdFormat.Unspecified),

};
sp.ServiceCertificates.Add(se);

IdentityProvider idp = new IdentityProvider(new EntityId(appSettings.Saml.EntityId), sp);
idp.Binding = Saml2BindingType.HttpPost;
idp.AllowUnsolicitedAuthnResponse = true;
//idp.WantAuthnRequestsSigned = true;
idp.SingleSignOnServiceUrl = new Uri("/login");
//idp.LoadMetadata = true;
idp.SigningKeys.AddConfiguredKey(new X509Certificate2(IdpCert));
idp.MetadataLocation = theMetadata;
idp.DisableOutboundLogoutRequests = true;

最佳答案

为了使注销工作,两个特殊声明“LogoutNameIdentifier”和“SessionIndex”(全名是 http://Sustainsys.se/Saml2/LogoutNameIdentifierhttp://Sustainsys.se/Saml2/SessionIndex 需要出现在用户身上。它们携带有关当前 session 的信息,Saml2 库需要能够做一个注销。

现在我没有看到你的整个 Startup,所以我无法理解你的应用程序的流程。但是这些声明应该存在于库返回的身份中 - 可能存储在外部 cookie 中(如果您使用的是 asp.net 身份)。当您的应用程序然后设置应用程序 cookie 时,这两个声明必须传递到 session 标识。

此外,您实际上已经使用 DisableOutboundLogoutRequests 禁用了出站注销。 .但这不是这里的主要问题,因为您的日志表明所需的声明不存在。

关于asp.net-core - 无法使用 Sustainsys 的 Saml2 注销,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58961868/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com