Support ASP.NET Core 2.0
Any updates here? When could release a version to support .net core 2.0?
There's a prerelease package on NuGet: https://www.nuget.org/packages/IdentityServer4/2.0.0-preview3
Yes but that's not a release. Many libraries that have a dependency on IdentityServer have their upgrades on hold because IdentityServer has not released a 2.0 update yet.
Given that it contains breaking changes, because ASP.NET Core 2.0.0 Identity has breaking changes, starting work against a prerelease package would probably get you ready sooner than waiting for the final 2.0.0 release of the package.
I agree this is helpful if you are developing with IdentityServer.
In my case, I'm using a framework that leverages IdentityServer, and I'm stuck waiting on them waiting on IdentityServer. I can't force them to develop against a prerelease version.
Has anyone tried using an asp.net core 2.0 Client?
Just tried updating one of our clients (which uses IdServer v4), but it is not working as expected, although the issue is on the client - not IdSrv. Instead of the client redirecting to the IdentityServer authority url as configured under AddOpenIdConnect it goes to /account/login - like if it were doing regular old identity auth and not recognizing the configuration.
Client's config in startup.cs looks like this
services.AddAuthentication(o => o.DefaultScheme = "Cookies")
.AddCookie(o => o.Cookie.Domain = settingSection.GetValue<string>("SiteDomainCookie") )
.AddOpenIdConnect(o =>
{
o.SignInScheme = "Cookies";
o.Authority = authority;
o.RequireHttpsMetadata = requireHttpsMetadata;
o.ClientId = clientId;
o.ClientSecret = clientSecret;
o.ResponseType = "code id_token";
o.Scope.Add("juntoz");
o.Scope.Add("offline_access");
o.GetClaimsFromUserInfoEndpoint = true;
o.SaveTokens = true;
});
// Add Identity
services.AddIdentity<IdentityAccount, IdentityRole>()
.AddUserStore<AccountStore>()
.AddRoleStore<RoleStore>();
@JamesReate, I am trying to do the same thing. Here is my Core 1.1 authentication code:
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
app.UseCookieAuthentication(
new CookieAuthenticationOptions
{
AuthenticationScheme = AuthenticationTypes.Cookies,
AutomaticAuthenticate = true,
AccessDeniedPath = "/AccessDenied",
ExpireTimeSpan = new TimeSpan(2, 0, 0)
});
app.UseOpenIdConnectAuthentication(
new OpenIdConnectOptions
{
AuthenticationScheme = "oidc",
Authority = "https://localhost:44316",
ClientId = "coretemplate",
ClientSecret = "secret",
GetClaimsFromUserInfoEndpoint = true,
PostLogoutRedirectUri = "https://localhost:44324",
RequireHttpsMetadata = true,
ResponseType = "code id_token",
Scope = { "openid", "profile", "name", "email", "role" },
SignInScheme = AuthenticationTypes.Cookies,
SaveTokens = true,
TokenValidationParameters = new TokenValidationParameters
{
NameClaimType = JwtClaimTypes.Name,
RoleClaimType = JwtClaimTypes.Role
}
});
which I have 'more or less' replicated for Core 2.0
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
services.AddAuthentication(
options =>
{
options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
})
.AddCookie(
options =>
{
options.SlidingExpiration = true;
options.AccessDeniedPath = "/AccessDenied";
options.ExpireTimeSpan = new TimeSpan(2, 0, 0);
})
.AddOpenIdConnect(
options =>
{
options.Authority = "https://localhost:44316";
options.ClientId = "coretemplate";
options.ClientSecret = "secret";
options.GetClaimsFromUserInfoEndpoint = true;
options.SignedOutRedirectUri = "https://localhost:44324";
options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.ResponseType = "code id_token";
options.RequireHttpsMetadata = true;
options.SaveTokens = true;
options.Scope.Add("openid");
options.Scope.Add("profile");
options.Scope.Add("name");
options.Scope.Add("email");
options.Scope.Add("role");
options.TokenValidationParameters = new TokenValidationParameters
{
NameClaimType = "name",
RoleClaimType = "role"
};
});
In Core 1.1 this works as expected i.e. authenticates against the Identity Server and returns the expected claims and roles. In Core 2.0 this almost works but the defined roles are not be mapped.
https://github.com/leastprivilege/AspNetCoreSecuritySamples/tree/aspnetcore2/OIDC
We are working on a 2.0 version - given the number of breaking changes between 1.0 and 2.0 - we need to re-test everything (in addition to substantial under-the-hood changes).
I would recommend everyone chills out a little bit - 2.0 hasn't even turned into an LTS version because also Microsoft needs more time to validate that their stuff is good enough.
For those living on the bleeding edge - go with 2.0 and use our preview package. For those that want stable and tested security software: it's done when it's done.
For using the IdentityServer4.AspNetIdentity, I do some simple workaround first just to make it work for my demo tonight. So far so good. Here is the link: https://github.com/IdentityServer/IdentityServer4.AspNetIdentity/issues/33#issuecomment-325934840
I just released another preview to nuget: 2.0.0-preview4. This should now be pretty well done for the new authentication changes in 2.0. Please have a look and provide any feedback. Given that I think all the major changes have been accounted for, I'll close this issue now. Again, if you find problems, please open a new issue.
Also, the quick start UI has been updated.
I'm now moving my attention to the EF and AspNetId projects now.
Looks like the .AddTemporarySigningCredential() is missing in the preview builds. Is this expected?
See #1139, use AddDeveloperSigningCredential instead.
As you find these sorts of things that are renamed or just moved, feel free to add to this: https://github.com/IdentityServer/IdentityServer4/issues/1057. That way we'll have a running list of what to update in the docs. Thanks.
For those of you that had problems co-hosting IdentityServer and an API in the same host, here's a sample: https://github.com/brockallen/IdentityServerAndApi
Hi everyone, i'd like to start a project for learning with Identity server and .net core and i'd like to start with .net core 2. Do you have any tutorial or guides on how everything can be done or do i have to start from version 1.1 and try to adapt to 2.0?
@pippo46 I think there are some articles, just googling it. I have noticed that https://github.com/aspnetboilerplate already used the .NET Core 2 with ID4. And I upgraded my sample code to .NET Core 2 yesterday as well. If you want, just have a look at https://github.com/thangchung/blog-core/tree/netcore2. Hope this help.
@thangchung thanks a lot, i'll give it a check
@thangchung - I looked at your blog-core code and noticed you add roles manually as claims to the token in identity server.
Is there a way to automatically include asp.net core identity roles in the identity server token? I still cannot get roles to come across in the token using asp.net core identity.
I set up my client as @leastprivilege shows here
In my IdentityServer config I have tried adding various Identity Resources (variants of Role, Roles) and in the client config allowed scopes.
I have looked for online examples of this on the IdentityServer and LeastPrivilege repos.
Is there a config setting I am missing to automatically load the roles from the standard asp.net core identity into the identity token claims, or must this be done manually?
@smoses2 You're right. I have added the role manually in the IdentityWithAdditionalClaimsProfileService class, but I think you could do it easier by getting all roles via UserManager