【发布时间】:2019-10-10 17:05:49
【问题描述】:
我有一个针对 ADFS 服务器进行身份验证的 ASP.NET Web API。 Authentication 启动类定义如下:
public void ConfigureAuth(IAppBuilder app)
{
app.UseCookieAuthentication(
new CookieAuthenticationOptions
{
AuthenticationType = WsFederationAuthenticationDefaults.AuthenticationType
});
app.UseWsFederationAuthentication(
new WsFederationAuthenticationOptions
{
MetadataAddress = ConfigurationManager.AppSettings["ADFSMetadata"],
Wtrealm = ConfigurationManager.AppSettings["Wtrealm"]
});
app.SetDefaultSignInAsAuthenticationType(WsFederationAuthenticationDefaults.AuthenticationType);
}
我想要的是,当用户成功通过 ADFS 身份验证并返回令牌时,如果在 ADFS 返回的声明中找到的电子邮件在数据库中不存在,则应在我的 SQL 数据库中创建用户记录已经。
有没有办法在认证后直接拦截响应以实现上述任务?
【问题讨论】:
标签: asp.net-web-api wif adfs3.0