【发布时间】:2020-11-06 01:37:29
【问题描述】:
尝试使用 Okta 处理 Single Log out 请求
我尝试在 Sustainsys 上使用示例代码,如下所示:
public async Task<IActionResult> Logout()
{
await _signInManager.SignOutAsync();
_logger.LogInformation("User logged out.");
return SignOut(new AuthenticationProperties()
{
RedirectUri = "/Index"
},
Saml2Defaults.Scheme);
}
但这似乎并没有调用 Single Log Out。我只是被重定向到我的注销页面。从我读过的内容来看,它是受支持的,所以不确定我应该调用什么。在启动时,我加载了其中包含 SLO url 的元数据,因此它应该知道指向哪里。
Okta 需要证书,所以我在启动时添加了相关的 pfx 文件,如下所示:
// Add Saml Athentication
var authBuilder = services.AddAuthentication();
authBuilder.AddSaml2(options =>
{
// SAML Okta options
options.SPOptions.EntityId = new EntityId(Configuration["SAML:AudienceURI"]);
// Set up redirect to SAML controller callback to handle log in after SAML Authentication (For Okta/IDP initiated log in)
options.SPOptions.ReturnUrl = new Uri(Configuration["SAML:ReturnURL"]);
// Scheme to handle the authentication
options.SignInScheme = IdentityConstants.ExternalScheme;
options.SignOutScheme = IdentityConstants.ApplicationScheme;
// Set up Identity Provider
var identityProvider = new IdentityProvider(
new EntityId(Configuration["SAML:EntityID"]),
options.SPOptions)
{
Binding = Saml2BindingType.HttpRedirect,
LoadMetadata = true,
MetadataLocation = Configuration["SAML:MetadataURL"],
AllowUnsolicitedAuthnResponse = true
};
options.SPOptions.ServiceCertificates.Add(new X509Certificate2("Okta.pfx", ""));
options.IdentityProviders.Add(identityProvider);
});
有什么想法吗?我必须手动完成吗?如果是这样,任何指针都会很棒。
【问题讨论】:
标签: asp.net-core saml saml-2.0 sustainsys-saml2