在AuthenticationOptions类上具有asp

在AuthenticationOptions类上具有asp

本文介绍了在AuthenticationOptions类上具有asp.net core2.0错误的IdentityServer4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正在使用ASP.NET Core 2.0开发Identity Server 4.

I am working on Identity Server 4 with asp.net core 2.0.

在我添加的ConfigurationServices()方法中:

In ConfigurationServices() method i added:

app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
        {
            Authority = "http://localhost:59391",
            RequireHttpsMetadata = false,

           ApiName = "api1"
        });

但是它给出了编译错误:

But it gives compile error that:

当我查看汇编代码时:

    namespace Microsoft.AspNetCore.Builder
    {
    public class IdentityServerAuthenticationOptions : Builder.AuthenticationOptions
    {
      // properties goes here
    }
    }

我基于示例项目(.网络核心1.1)和AuthenticationOptions构建错误在 Github链接中进行了很多讨论但是好像ASP.NET core2.0尚未完全支持Identity Server4.是真的吗?

I worked based on this sample project (.net core 1.1) and AuthenticationOptions build error was discussed a lot in this Github link but seems like Identity Server 4 not fully supported yet with asp .net core2.0.Is it true?

请分享您的想法,如何解决此错误或如何解决此问题.

Please share your thoughts how to resolve this error or how to workaround this issue.

推荐答案

是正确的-在ASP.NET Core 2.0中更改了身份验证中间件.我相信有一个 2.0版IndentityServer4.AccessTokenValidation的候选版本;但是,目前,Identity Server文档和示例尚未针对2.0进行更新.

That's correct - authentication middleware changed in asp.net core 2.0. I believe there is a release candidate of IndentityServer4.AccessTokenValidation for 2.0; however, at the moment, the Identity Server docs and samples have not been updated for 2.0.

一种选择是使用Microsoft JwtBearer处理程序来保护您的api. IdentityServer4.AccessTokenValidation库在内部使用此功能.看起来像这样(在ConfigureServices()里面):

One option is to use the Microsoft JwtBearer handler to secure your api. The IdentityServer4.AccessTokenValidation library uses this under the hood. It would look something like this (inside ConfigureServices()):

services.AddAuthentication(o =>
{
    o.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
    o.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddJwtBearer(o =>
{
    o.Audience = "api1";
    o.Authority = "http://localhost:59391";
    o.RequireHttpsMetadata = false;
});

另一种选择是更新代码以使用 IdentityServer4.AccessTokenValidation 2.0 rc .我还没有尝试过,但是看起来像这样:

Another option is to update your code to use the IdentityServer4.AccessTokenValidation 2.0 rc. I haven't tried this yet but it would look something like this:

services.AddAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme)
.AddIdentityServerAuthentication(o =>
{
    o.ApiName = "api1";
    o.Authority = "http://localhost:59391";
    o.RequireHttpsMetadata = false;
});

这篇关于在AuthenticationOptions类上具有asp.net core2.0错误的IdentityServer4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 16:04