Authentication 使用ADFS WS-Fed协议进行身份验证和授权

Authentication 使用ADFS WS-Fed协议进行身份验证和授权,authentication,authorization,asp.net-web-api2,jwt,adfs3.0,Authentication,Authorization,Asp.net Web Api2,Jwt,Adfs3.0,我正在我的应用程序中实现身份验证和授权 用于身份验证: 我使用WS-Fed登录协议配置了ADFS服务器,并启用了JWT。创建MVC应用程序并配置为使用WS-Fed对用户进行身份验证 现在的问题是,在成功登录后,如何将JWT令牌存储在cookie中 这是我的密码 public partial class Startup { private static string realm = ConfigurationManager.AppSettings["ida:Wtrealm"

我正在我的应用程序中实现身份验证和授权

用于身份验证: 我使用WS-Fed登录协议配置了ADFS服务器,并启用了JWT。创建MVC应用程序并配置为使用WS-Fed对用户进行身份验证

现在的问题是,在成功登录后,如何将JWT令牌存储在cookie中

这是我的密码

public partial class Startup
    {
        private static string realm = ConfigurationManager.AppSettings["ida:Wtrealm"];
        private static string adfsMetadata = ConfigurationManager.AppSettings["ida:ADFSMetadata"];

        public void ConfigureAuth(IAppBuilder app)
        {
            app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
            app.UseCookieAuthentication(new CookieAuthenticationOptions{ CookieName="JwtToken",CookieHttpOnly=false});
            app.UseWsFederationAuthentication(
                new WsFederationAuthenticationOptions
                {
                    Wtrealm = realm,
                    MetadataAddress = adfsMetadata
                });
        }
    }
用于授权 我有一个单独的Web API项目。我想通过在每个请求的头中传递JWT令牌来授权我的api,但不确定如何从cookie中提取JWT令牌并将其传递给web api进行验证。

我在这里找到了答案

ADAL(针对.NET和JavaScript的Active Directory身份验证库),可用于在mvc应用程序中获取令牌,并在标头中传递令牌以授权web api。

我在这里找到了答案

ADAL(针对.NET和JavaScript的Active Directory身份验证库),可用于在mvc应用程序中获取令牌,并在标头中传递令牌以授权web api