前言开发授权服务框架一般使用OAuth2.0授权框架,而开发Webapi的授权更应该使用OAuth2.0授权标准,OAuth2.0授权框架文档说明参考:https://tools.ietf.org/html/rfc6749.NET Core开发OAuth2的项目需要使用Ident ...
前言
开发授权服务框架一般使用OAuth2.0授权框架,而开发Webapi的授权更应该使用OAuth2.0授权标准,OAuth2.0授权框架文档说明参考:https://tools.ietf.org/html/rfc6749
.NET Core开发OAuth2的项目需要使用IdentityServer4(现在还处于RC预发行版本),可参考:https://identityserver4.readthedocs.io/en/dev/
IdentityServer4源码:https://github.com/IdentityServer
如果在.NET中开发OAuth2的项目可使用OWIN,可参考实例源码:https://www.get='_blank'>asp.net/aspnet/overview/owin-and-katana/owin-oauth-20-authorization-server
实现ResourceOwnerPassword和client credentials模式:
授权服务器:
Program.cs --> Main方法中:需要调用UseUrls设置IdentityServer4授权服务的IP地址
1 var host = new WebHostBuilder()2 .UseKestrel()3 //IdentityServer4的使用需要配置UseUrls4 .UseUrls("http://localhost:4537")5 .UseContentRoot(Directory.GetCurrentDirectory())6 .UseIISIntegration()7 .UseStartup<Startup>()8 .Build();
海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com
原标题:ASP.NET Core实现OAuth2.0的ResourceOwnerPassword和ClientCredentials模式
关键词:ASP.NET
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。