IdentityServer4 icon indicating copy to clipboard operation
IdentityServer4 copied to clipboard

Support ASP.NET Core 2.0

Open brockallen opened this issue 9 years ago • 84 comments

brockallen avatar Apr 12 '17 14:04 brockallen

why don't you run build.ps1 yourself - the result will be a nuget package...

leastprivilege avatar Jul 16 '17 07:07 leastprivilege

First nuget with aspnet core 2 preview2 support:

https://www.nuget.org/packages/IdentityServer4/2.0.0-preview2

Give it a try and let us know what's not working...

leastprivilege avatar Jul 19 '17 06:07 leastprivilege

Awesome! Will the other packages like identityServer4 with ASP Net identity or JWT Authentication work fine or do they need to be updated as well?

On Wed, Jul 19, 2017 at 7:54 AM, Dominick Baier [email protected] wrote:

First nuget with aspnet core 2 preview2 support:

https://www.nuget.org/packages/IdentityServer4/2.0.0-preview2

Give it a try and let us know what's not working...

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/IdentityServer/IdentityServer4/issues/1055#issuecomment-316290372, or mute the thread https://github.com/notifications/unsubscribe-auth/AFqqs65RRaXWJlVqh-5eiRNA62NcYFRmks5sPag5gaJpZM4M7gaj .

lukasportal avatar Jul 19 '17 07:07 lukasportal

they also need updating.

leastprivilege avatar Jul 19 '17 07:07 leastprivilege

Hi , Thanks for the great work . i'm trying to implement IDS4 in Core 2.0 ,i also update IDS4 using below nuget comment " Install-Package IdentityServer4 -Pre" , i'm getting following error

app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions { //Identity Server URL Authority = "http://localhost:49370", RequireHttpsMetadata = false, ApiName = "api1" });

Severity Code Description Project File Line Suppression State Error CS7069 Reference to type 'AuthenticationOptions' claims it is defined in 'Microsoft.AspNetCore.Authentication', but it could not be found

cdamose avatar Jul 20 '17 06:07 cdamose

The access token validation middleware hasn't been ported. Use Microsoft's JwtBearer as a replacement for now.

leastprivilege avatar Jul 20 '17 07:07 leastprivilege

@leastprivilege am i correct ? ** app.UseJwtBearerAuthentication(new JwtBearerOptions { Authority= "http://localhost:49370", RequireHttpsMetadata=false });**

is this correct way?

cdamose avatar Jul 20 '17 07:07 cdamose

And Audience

leastprivilege avatar Jul 20 '17 08:07 leastprivilege

I'm getting following everity Code Description Project File Line Suppression State Error CS0619 'JwtBearerAppBuilderExtensions.UseJwtBearerAuthentication(IApplicationBuilder, JwtBearerOptions)' is obsolete: 'See https://go.microsoft.com/fwlink/?linkid=845470'

can you provide any suggestion

cdamose avatar Jul 20 '17 08:07 cdamose

Well - there are breaking changes in aspnetcore2 - this is not really the place to discuss them - but have a look here

https://github.com/aspnet/Announcements/issues/262

leastprivilege avatar Jul 20 '17 09:07 leastprivilege

services.AddJwtBearerAuthentication(o => { o.Authority = "http://localhost:49371/"; o.Audience = "myapi"; });

IDS4 running in this URL "http://localhost:49371" ,but i's not authorize
image its showing 500 error , am i wrong in my configuration?

cdamose avatar Jul 31 '17 14:07 cdamose

Maybe try setting the DefaultAuthenticate Scheme to JwtBearer Scheme? This works for me.

            services.AddAuthentication(options =>
            {
                options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
            });

Or disable https

            services.AddJwtBearerAuthentication(o =>
            {
                o.Audience = "myapi";
                o.Authority = "http://localhost:5000";
                o.RequireHttpsMetadata = false;
            });

KalBence avatar Aug 01 '17 09:08 KalBence

Still same issue :( 401 unauthorized ,
services.AddJwtBearerAuthentication(o => { o.Authority = "http://localhost:49371/";

            o.Audience = "http://localhost:49371/resources";
            o.RequireHttpsMetadata = false;
           
        });

cdamose avatar Aug 01 '17 09:08 cdamose

Did you put app.UseAuthentication(); before app.UseMvc(); in the Configure method?

KalBence avatar Aug 01 '17 11:08 KalBence

Yes @KalBence

cdamose avatar Aug 01 '17 11:08 cdamose

in configure method app.UseAuthentication();

in ConfigureServices method

services.AddJwtBearerAuthentication(o => { o.Authority = "http://localhost:49371/";

            o.Audience = "http://localhost:49371/resources";
            o.RequireHttpsMetadata = false;

});

cdamose avatar Aug 01 '17 11:08 cdamose

image

this is my request

cdamose avatar Aug 01 '17 11:08 cdamose

Remove the last '/' from o.Authority = "http://localhost:49371/"; to, o.Authority = "http://localhost:49371";

rizamarhaban avatar Aug 01 '17 11:08 rizamarhaban

I hope this helps someone trying to use Identity Server with net Core 2 following the IDS4 Tutorial.

There is not full support for all the identity server 4 packages for Net Core 2 Yet, the workaround it's build up your Identity Server with net core 1.1, and you can validate tokens from resources build in net core 2.0 using Microsoft JwtBearer like this:

After creating the api add this to ConfigureServices

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

and change this code in Configure Method (As written in the tutorial):

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

    ApiName = "api1"
});

for this (Remember just before app.UseMvc() ):

app.UseAuthentication();

This is a workaround while the rest of the identity server nuget's get updated to net core 2.0 !

In the meantime I'll keep testing the project.

Good work guys ! and Awesome project ! Keep it up please !

DavidNorena avatar Aug 10 '17 14:08 DavidNorena

Dear,

I'm following the official documentation on how to implement my first ID4 server on ASPNET CORE 2.0, but when i try to debug the application i encounter the exception:

System.MissingMethodException:'Method not found: 'Microsoft.Extensions.DependencyInjection.IServiceCollection Microsoft.Extensions.DependencyInjection.AuthenticationServiceCollectionExtensions.AddAuthentication(Microsoft.Extensions.DependencyInjection.IServiceCollection)'.'

My ConfigureServices() is this:

var migrationsAssembly = typeof(Startup).GetType().Assembly.GetName().Name;
services.AddMvc();
            services.AddIdentityServer()
                .AddTemporarySigningCredential()
                .AddTestUsers(Config.GetUsers())
                .AddConfigurationStore(builder =>
                    builder.UseSqlServer(Configuration.GetConnectionString("credential"), options =>
                        options.MigrationsAssembly(migrationsAssembly)))
                .AddOperationalStore(builder =>
                    builder.UseSqlServer(Configuration.GetConnectionString("credential"), options =>
                        options.MigrationsAssembly(migrationsAssembly)));

My NuGets are:

  • IdentityServer4.AspNetIdentity 1.0.1
  • IdentityServer4.EntityFramework 1.0.1
  • All MS packages are 2.0.0

I tried also using IdentitServer4 => v2.0.0-preview2 but the error remain.

Do you have some suggestion?

michaelsogos avatar Aug 13 '17 20:08 michaelsogos