b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

scopes .NET Core微服务之基于IdentityServer建

电脑杂谈  发布时间:2019-03-20 20:07:59  来源:网络整理

新建两个WebAPI程序,假设这里取名为ApiService01(占用端口5010)和ApiService02(占用端口5020)。

为了方便快速启动,可以继续在launchSettings.json中删掉关于IISExpress的部分,由于是WebAPI,所以也不需要启动浏览器(将其设为false):

NuGet>Install-Package IdentityServer4.AccessTokenValidation

    public void ConfigureServices(IServiceCollection services)
    {
        ......

        // IdentityServer
        services.AddMvcCore().AddAuthorization().AddJsonFormatters();
        services.AddAuthentication(Configuration["Identity:Scheme"])
            .AddIdentityServerAuthentication(options =>
            {
                options.RequireHttpsMetadata = false; // for dev env
                options.Authority = $"http://{Configuration["Identity:IP"]}:{Configuration["Identity:Port"]}";
                options.ApiName = Configuration["Service:Name"]; // match with configuration in IdentityServer
            });

        // Swagger
        ......
    }

{
  "Service": {
    "Name": "clientservice",
    "Port": "5010",
    "DocName": "clientservice",
    "Version": "v1",
    "Title": "CAS Client Service API",
    "Description": "CAS Client Service API provide some API to help you get client information from CAS",
    "Contact": {
      "Name": "CAS 2.0 Team",
      "Email": "EdisonZhou@manulife.com"
    },
    "XmlFile": "Manulife.DNC.MSAD.IdentityServer4Test.ApiService01.xml"
  },
  "Identity": {
    "IP": "localhost",
    "Port": "5000",
    "Scheme": "Bearer"
  }
}

此外,还需要在Configure方法中配置Authentication中间件:这里需要注意的就是需要放在UseMvc()之前调用。


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/tongxinshuyu/article-92987-1.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    每日福利
    热点图片
    拼命载入中...