【发布时间】:2015-11-13 23:04:05
【问题描述】:
在针对 ADFS 进行身份验证后,一直在努力尝试提取不记名令牌...
我有一个 API 可以接受 Bearer 令牌并针对 ADFS 对其进行验证。
我有一个 Web 表单 (.net 4.5.1) 应用程序,我正在修改它以使用 ADFS 3.0 来实现 SSO 身份验证。到目前为止,它已针对 ADFS 服务器正确进行身份验证(显示到 ADFS 登录页面并登录)。
我的问题是我现在希望 WebForms 应用使用我希望在 ADFS 返回的响应中某处存在的不记名令牌调用我的 Web API,但它在哪里以及如何检索它?
我尝试使用 SecurityTokenValidated 和 SecurityTokenReceived WsFederationAuthenticationNotifications 事件,如下所示:
public void ConfigureAuth(IAppBuilder app)
{
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseWsFederationAuthentication(
new WsFederationAuthenticationOptions
{
AuthenticationType = WsFederationAuthenticationDefaults.AuthenticationType, // "WS-Fed Auth (Primary)",
Wtrealm = realm,
MetadataAddress = metadata,
Notifications = new WsFederationAuthenticationNotifications
{
AuthenticationFailed = context =>
{
context.HandleResponse();
context.Response.Redirect("Home/Error?message=" + context.Exception.Message);
return Task.FromResult(0);
},
SecurityTokenValidated = token =>
{
Token = token.AuthenticationTicket.ToString();
return Task.FromResult(0);
},
SecurityTokenReceived = token =>
{
Token = token.ToString();
return Task.FromResult(0);
}
}
});
}
但是我在事件返回的对象中的任何地方都找不到令牌... 我错过了什么?
感谢大家的帮助。
【问题讨论】:
标签: c# asp.net owin katana adfs3.0