.NET Core 2.0 support
- [x] I read and understood how to enable logging
Issue / Steps to reproduce the problem
Trying to authenticate a ASP.NET Core 2.0 project with IdentityServer4. However the authentication part of ASP.NET has undergone some major changes: https://github.com/aspnet/Announcements/issues/232
The only issue so far is:
Reference to type 'AuthenticationOptions' claims it is defined in 'Microsoft.AspNetCore.Authentication', but it could not be found
Startup.cs:
using IdentityServer4.AccessTokenValidation;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Serialization;
using System;
using System.IdentityModel.Tokens.Jwt;
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.AspNetCore.Authentication.Cookies;
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)
{
// Authenticate with IdentityServer4
services.AddAuthentication(options => {
options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
});
// Add framework services
services.AddMvc();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IServiceProvider serviceProvider)
{
// Authenticate with IdentityServer4
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
{
Authority = Configuration.GetValue<string>("Authentication:Authority"),
ApiName = Configuration.GetValue<string>("Authentication:ApiName"),
ApiSecret = Configuration.GetValue<string>("Authentication:ApiSecret"),
SupportedTokens = SupportedTokens.Both,
RequireHttpsMetadata = false
});
app.UseMvc();
}
}
}
Project.csproj:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
</PropertyGroup>
<PropertyGroup>
<PackageTargetFallback>$(PackageTargetFallback);dnxcore50;portable-net451+win8</PackageTargetFallback>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="1.2.0" />
<PackageReference Include="IdentityServer4.AspNetIdentity" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0-preview1-final" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0-preview1-final" />
</ItemGroup>
</Project>
Relevant parts of the log file
N/A
https://github.com/IdentityServer/IdentityServer4/issues/1055
v1 and v2 of aspnet core and not compatible. Run IdentityServer on asp.net core 1.x for the time being.
Dup: https://github.com/IdentityServer/IdentityServer4/issues/1055
When will the IdentityServer4 example projects implementing the .NET Core 2.0 SDK be available? Can I sign up on a list to get notified when they do? Thanks.
Interested here as well. When will 2.0 support be available?
Same issue here. Please post the solution once updated
It's available in this repo... Host project: https://github.com/IdentityServer/IdentityServer4/tree/dev/src/Host Nuget package: https://preview.nuget.org/packages/IdentityServer4/2.0.0-preview4
Erwin:
Thanks for the update! My company has had great success in implementing our proto-type projects with IdentityServer4 (v1.0) and definitely has its sights set on upgrading to v2.0 just as soon as our “Proof-Of-Concept” (POC) has been demonstrated.
Good work to you and the IdentityServer team for an outstanding, Open Source product that really meets the demands of today’s ever-changing complexities for real-world Internet products. Ones that require Secure Servers to dispense top-notch, quality services and products.
Regards,
Robert Hyland
President & CEO,
Hyland Computer Systems, L.L.C
From: Erwin Wildenburg [mailto:[email protected]] Sent: Saturday, September 2, 2017 12:33 PM To: IdentityServer/IdentityServer4 [email protected] Cc: Hyland Computer Systems, L.L.C. [email protected]; Comment [email protected] Subject: Re: [IdentityServer/IdentityServer4] .NET Core 2.0 support (#1173)
It's available in this repo... Host project: https://github.com/IdentityServer/IdentityServer4/tree/dev/src/Host Nuget package: https://preview.nuget.org/packages/IdentityServer4/2.0.0-preview4
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/IdentityServer/IdentityServer4/issues/1173#issuecomment-326762091 , or mute the thread https://github.com/notifications/unsubscribe-auth/ADtu5GaxTAXera9qS0yS0KBp6daaHudAks5seZ9UgaJpZM4NbgGf .
Hello everyone,
I still have the same issue:
Reference to type 'AuthenticationOptions' claims it is defined in 'Microsoft.AspNetCore.Authentication', but it could not be found.
here: app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions...
I have: "IdentityServer4" Version="2.0.0-preview4" "IdentityServer4.AccessTokenValidation" Version="1.2.1"
Hi vitalbsk
I had the same issue. I removed Microsoft.AspNetCore.All (2.0.0) package and added Microsoft.AspNetCore (2.0.0) & Microsoft.AspNetCore.Mvc (2.0.0), I'm not sure how but it resolved my issue.
@shanakaip thanks. But it doesn't work for me.
We just released RC1 today. Have a look, and you should be looking at the updates quickstart UI code.
We just released RC1 today. Have a look, and you should be looking at the updates quickstart UI code.
I just tried installing the latest IdentityServer4 RC1 package from nuget and I still get the same error,
"error CS7069: Reference to type 'AuthenticationOptions' claims it is defined in 'Microsoft.AspNetCore.Authentication', but it could not be found"
:(
My guess is that you're trying to upgrade an old 1.1 app. You need to gut the csproj and start clean. That's not an IdentityServer problem.
My guess is that you're trying to upgrade an old 1.1 app. You need to gut the csproj and start clean. That's not an IdentityServer problem.
It's actually a fresh Asp.Net Core 2 WebAPI. Just to make sure following on from what you said I created a new WebAPI project for Asp.Net Core 2 and added the same call to UseIdentityServerAuthentication and got the same error:
app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
{
Authority = "http://localhost:50151",
RequireHttpsMetadata = false,
ApiName = "scope.readaccess"
});
Ah, I assumed this was in the IdentityServer host. UseIdentityServerAuthentication is our authentication middleware -- it's not yet been ported to ASP.NET Core 2. Use the Jwt Bearer from Microsoft in the meantime.
@meds you can see from my working demo code on how to setup: https://github.com/rizamarhaban/IdentityServer4Demo
Ah, I assumed this was in the IdentityServer host. UseIdentityServerAuthentication is our authentication middleware -- it's not yet been ported to ASP.NET Core 2. Use the Jwt Bearer from Microsoft in the meantime.
Any ETA when this will be supported?
Any update on that?
rc1 has been released two weeks ago.