.NET Core和JSON Web令牌,还需要Owin吗? [英] .NET Core and JSON Web Tokens, still need Owin?

查看:85
本文介绍了.NET Core和JSON Web令牌,还需要Owin吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

第一次在.net核心中执行此操作,我已经使用这些教程设置了JWT auth/ASP Identity数据库,两者都很不错:

first time doing this in .net core, I've set up JWT auth / ASP Identity database using these tutorials, both of which are quite good:

https://www.youtube.com/watch?v=yH4GhmTPf68

https://www.youtube.com/watch?v=vEU9SDmIvVY

但是,几年前进行设置时,我使用了OWin.我无法同时使用JWT和Owin在.Net Core上查找资源.JWT是否本身在.Net Core中是安全的,还是我们仍然需要Owin?

However, when I set this up a few years ago, I used OWin. I'm having trouble finding resources on .Net Core using both JWT and Owin. Is JWT secure by itself in .Net Core or do we still need Owin?

推荐答案

简短的回答是否".在.net核心上,无需在使用JWT令牌时手动设置OWIN.

The short answer is No. At .net core, there is no need to set up OWIN manually as you are using JWT token.

没有理由像在WebAPI 2上那样实现OWIN.在net.core启动文件中,您会注意到一个类似于以下内容的Configure函数

There is no reason to implement OWIN like the old days at WebAPI 2. Inside net.core Startup file, you will notice a Configure function that looks similar like this

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    if (env.IsDevelopment())
    {
        app.UseDeveloperExceptionPage();
    }
    else
    {
        // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
        app.UseHsts();
    }

    app.UseAuthentication();
    app.UseHttpsRedirection();
    app.UseMvc();
}

您现在将在此文件中配置服务,并在此文件中注册身份验证服务.当我将Web应用程序从Web API 2升级到.NET Core 2进行身份验证服务器时,这是一个很好的资源.

You will now Configure the services inside this file and registering the authentication services inside this file. Here is a good resource that I used when I'm upgrading my web app from Web API 2 to .NET core 2 for my authentication server.

https://andrewlock.net/a-look-the-jwt-bearer-authentication-middleware-in-asp-net-core/

这篇关于.NET Core和JSON Web令牌,还需要Owin吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆