当前位置: 首页 > news >正文

手机网站用什么做郑州网站开发设计公司电话

手机网站用什么做,郑州网站开发设计公司电话,wordpress未收到数据,做直播网站宽带一、简介IdentityServer4是用于ASP.NET Core的OpenID Connect和OAuth 2.0框架。将IdentityServer4部署到您的应用中具备如下特点#xff1a;1#xff09;、认证服务2#xff09;、单点登陆3#xff09;、API访问控制4#xff09;、联合网关5#xff09;、专注于定制6  1、认证服务  2、单点登陆  3、API访问控制  4、联合网关  5、专注于定制  6、成熟的开源系统  7、免费和商业支持二、整体部署   目前大多数的应用程序或多或少看起来是上图所示这样的最常见的交互场景有浏览器与Web应用程序、Web应用程序与WebApi通讯、本地应用程序狱WebApi通讯、基于浏览器的应用程序与WebApi 通讯、基本服务器的应用程序与WebApi通讯、WebApi与WebApi通讯  前端、中间层、后端各个层级为了保护资源经常要针对相同的用户仓储区实现身份认证和授权但是如果我们把这些基本的安全功能统一颁发给一个安全令牌服务就可以不必再让这些应用和端点之间重复实现这些基础安全功能重组应用程序以支持安全令牌服务将会引导出以下体系结构和协议   这样的设计将会把安全问题分为两个部分身份验证和API访问三、IdentityServer4如何提供帮助  IdentityServer是将规范兼容的OpenID Connect和OAuth 2.0端点添加到任意ASP.NET Core应用程序的中间件。通常您构建或重新使用包含登录和注销页面的应用程序IdentityServer中间件会向其添加必要的协议头以便客户端应用程序可以与其对话 使用这些标准协议。 四、术语      1、Users用户用户是使用已注册的客户端访问资源的人     2、Clients客户端客户端就是从identityserver请求令牌的软件你可以理解为一个app即可既可以通过身份认证令牌来验证识别用户身份又可以通过授权令牌来访问服务端的资源。但是客户端首先必须在申请令牌前已经在identityserver服务中注册过。实际客户端不仅可以是Web应用程序app或桌面应用程序你就理解为pc端的软件即可SPA服务器进程等  3)、Resources资源  资源就是你想用identityserver保护的东东可以是用户的身份数据或者api资源。  用户的身份信息实际由一组claim组成例如姓名或者邮件都会包含在身份信息中将来通过identityserver校验后都会返回给被调用的客户端。  API资源就是客户端想要调用的功能通常以json或xml的格式返回给客户端例如webapiwcf,webservice通常通过webapi来建立模型但是不一定是webapi我刚才已经强调可以使其他类型的格式这个要看具体的使用场景了。  4、Identity Token身份令牌  一个身份令牌指的就是对认证过程的描述。它至少要标识某个用户Called the sub aka subject claim的主身份信息和该用户的认证时间和认证方式。但是身份令牌可以包含额外的身份数据具体开发者可以自行设定但是一般情况为了确保数据传输的效率开发者一般不做过多额外的设置大家也可以根据使用场景自行决定。  5、Access Token访问令牌   访问令牌允许客户端访问某个 API 资源。客户端请求到访问令牌然后使用这个令牌来访问 API资源。访问令牌包含了客户端和用户如果有的话这取决于业务是否需要但通常不必要的相关信息API通过这些令牌信息来授予客户端的数据访问权限。五、代码快速入门 (使用客户端凭据保护)  1、IdentityServer     a)、定义Api资源和客户端      Api 是您系统中要保护的资源资源的定义可以通过多种方式      客户端代码中的ClientId和ClientSecret你可以视为应用程序本身的登录名和密码它将您的应用程序标识到IdentityServer 服务器以便它知道哪个应用程序正在尝试与其连接using IdentityServer4.Models; using System.Collections.Generic; namespace IdentityServer { public static class Config { public static IEnumerableApiResource Apis new ListApiResource { new ApiResource(api1,My API) }; public static IEnumerableClient Clients new ListClient { new Client { ClientIdclient, AllowedGrantTypes GrantTypes.ClientCredentials, ClientSecrets{ new Secret(aju.Sha256()) }, AllowedScopes{ api1} } }; } }        b)、配置IdentityServerusing Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; namespace IdentityServer { public class Startup { // This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID398940 public void ConfigureServices(IServiceCollection services) { var builder services.AddIdentityServer() .AddInMemoryApiResources(Config.Apis) .AddInMemoryClients(Config.Clients); builder.AddDeveloperSigningCredential(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseIdentityServer(); //app.UseRouting(); //app.UseEndpoints(endpoints //{ // endpoints.MapGet(/, async context // { // await context.Response.WriteAsync(Hello World!); // }); //}); } } }        c)、测试如果配置合适在浏览器访问 http://localhost:5000/.well-known/openid-configuration  出现如下表示配置OK首次启动时IdentityServer将为您创建一个开发人员签名密钥该文件名为tempkey.rsa。您无需将该文件签入源代码管理中如果不存在该文件将被重新创建。    d)、所需的包  2、添加Api资源      a)、添加一个名为IdentityController的控制器using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System.Linq; namespace Api.Controllers { [Route(identity)] [Authorize] public class IdentityController : ControllerBase { public IActionResult Get() { return new JsonResult(from c in User.Claims select new { c.Type, c.Value }); } } }        b)、配置将身份认证服务添加到DI并将身份验证中间件添加到管道    using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; namespace Api { public class Startup { public Startup(IConfiguration configuration) { Configuration configuration; } public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); services.AddAuthentication(Bearer).AddJwtBearer(Bearer, options { options.Authority http://localhost:5000; options.RequireHttpsMetadata false; options.Audience api1; }); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseRouting(); app.UseAuthentication();//认证 app.UseAuthorization();//授权 app.UseEndpoints(endpoints { endpoints.MapControllers(); }); } } }        AddAuthentication将身份认证服务添加到DI比配置Bearer为默认   AddAuthentication将身份认证服务添加到管道中以便对主机的每次调用都将自动执行身份验证   AddAuthentication添加授权中间件以确保匿名客户端无法访问我们的API资源   http://localhost:5001/identity 在浏览器上访问应返回401状态代码。这意味着您的API需要凭据并且现在受IdentityServer保护。          c)、所需的包3、创建客户端已控制台的形式using IdentityModel.Client; using Newtonsoft.Json.Linq; using System; using System.Net.Http; using System.Threading.Tasks; namespace Client { class Program { static async Task Main(string[] args) { // Console.WriteLine(Hello World!); var client new HttpClient(); var disco await client.GetDiscoveryDocumentAsync(http://localhost:5000); if (disco.IsError) { Console.WriteLine(disco.Error); return; } var tokenResponse await client.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest { Address disco.TokenEndpoint, ClientId client, ClientSecret aju, Scope api1 }); if (tokenResponse.IsError) { Console.WriteLine(tokenResponse.Error); return; } Console.WriteLine(tokenResponse.Json); Console.WriteLine(\n\n); //call api var apiClient new HttpClient(); apiClient.SetBearerToken(tokenResponse.AccessToken); var response await apiClient.GetAsync(http://localhost:5001/identity); if (!response.IsSuccessStatusCode) { Console.WriteLine(response.StatusCode); } else { var content await response.Content.ReadAsStringAsync(); Console.WriteLine(JArray.Parse(content)); } Console.ReadLine(); } } }        a)、所需的包   4、使用客户端访问Api资源  六、参考文献  http://docs.identityserver.io/en/latest/index.html扫码关注您将得到及时的文章推送信息
http://wiki.neutronadmin.com/news/265547/

相关文章:

  • 纯html网站模板江苏有什么网站找工程建设人员
  • 个人网站可以备案了吗学计算机网站建设
  • 浪琴手表网站建设图北京网站优化推广分析
  • 免费做简单网站企业培训考试
  • 网站建设h5渭南建设用地规划查询网站
  • 兰州建设局网站公告网站跟app的区别是什么
  • 深圳公众号开发公司百度网站优化软件
  • 做网站工作内容内蒙古市最新新闻
  • 抢注域名网站怎么弄一个电商平台
  • 看优秀摄影做品的网站培训网站建设公司排名
  • 如何创建一个论坛网站莱芜网络推广公司电话
  • 用jsp做一网站的流程品牌建设方案的完整纲要
  • 设计网站都有什么北京市网站公司网站
  • 漳州城乡建设局网站首页哪些经营范围可以开网站建设费用
  • 密云城市建设官方网站营销策划网站
  • 手机网站制作教程软件网络购物系统参考文献
  • 常德市建设工程造价网站网站后台管理规定
  • 南阳网站开发公司广州 网站优化
  • h5开发环境济南网站优化排名推广
  • 宣城市建设监督管理局网站首页完整的营销策划方案
  • 智慧团建团员登录网站网站 域名解析出错
  • 江苏建设行业证书编号查询网站电商公司组织架构图
  • 商城网站服务器租用视频制作流程
  • 建设通网站怎么注销微信小程序开发介绍
  • 会展相关网站建设柳州市建设中心网站首页
  • seo包括网站建设吗福建厦门网站建设公司
  • 建设一个旅游网站网络营销心得体会
  • 网站建设项目的工期计划英文网站建设合同
  • 大眼睛网站建设html个人博客完整代码
  • 大企业网站建设方案中国互联网前100名企业