Skip to content
This repository was archived by the owner on Dec 20, 2018. It is now read-only.

Commit a9f75e5

Browse files
committed
Remove UseIdentity
1 parent 71e7e26 commit a9f75e5

File tree

6 files changed

+78
-59
lines changed

6 files changed

+78
-59
lines changed

Identity.sln

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Microsoft Visual Studio Solution File, Format Version 12.00
22
# Visual Studio 15
3-
VisualStudioVersion = 15.0.26123.0
3+
VisualStudioVersion = 15.0.26228.0
44
MinimumVisualStudioVersion = 10.0.40219.1
55
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{0F647068-6602-4E24-B1DC-8ED91481A50A}"
66
EndProject
@@ -26,6 +26,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNet.Identity.A
2626
EndProject
2727
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Identity.Specification.Tests", "src\Microsoft.AspNetCore.Identity.Specification.Tests\Microsoft.AspNetCore.Identity.Specification.Tests.csproj", "{5608E828-DD54-4E2A-B73C-FC22268BE797}"
2828
EndProject
29+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authentication.Cookies", "..\Security\src\Microsoft.AspNetCore.Authentication.Cookies\Microsoft.AspNetCore.Authentication.Cookies.csproj", "{D747780A-7C44-4714-AD6C-3B226A7EB2FB}"
30+
EndProject
31+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authentication.Abstractions", "..\Security\src\Microsoft.AspNetCore.Authentication.Abstractions\Microsoft.AspNetCore.Authentication.Abstractions.csproj", "{2BE313F5-3ED6-4F85-ACDD-AA8F96409E91}"
32+
EndProject
33+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authentication.Impl", "..\Security\src\Microsoft.AspNetCore.Authentication.Impl\Microsoft.AspNetCore.Authentication.Impl.csproj", "{5D7B7984-542F-4DEA-8C2F-EBE44E6AE03D}"
34+
EndProject
2935
Global
3036
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3137
Debug|Any CPU = Debug|Any CPU
@@ -130,6 +136,42 @@ Global
130136
{5608E828-DD54-4E2A-B73C-FC22268BE797}.Release|Mixed Platforms.Build.0 = Release|Any CPU
131137
{5608E828-DD54-4E2A-B73C-FC22268BE797}.Release|x86.ActiveCfg = Release|Any CPU
132138
{5608E828-DD54-4E2A-B73C-FC22268BE797}.Release|x86.Build.0 = Release|Any CPU
139+
{D747780A-7C44-4714-AD6C-3B226A7EB2FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
140+
{D747780A-7C44-4714-AD6C-3B226A7EB2FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
141+
{D747780A-7C44-4714-AD6C-3B226A7EB2FB}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
142+
{D747780A-7C44-4714-AD6C-3B226A7EB2FB}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
143+
{D747780A-7C44-4714-AD6C-3B226A7EB2FB}.Debug|x86.ActiveCfg = Debug|Any CPU
144+
{D747780A-7C44-4714-AD6C-3B226A7EB2FB}.Debug|x86.Build.0 = Debug|Any CPU
145+
{D747780A-7C44-4714-AD6C-3B226A7EB2FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
146+
{D747780A-7C44-4714-AD6C-3B226A7EB2FB}.Release|Any CPU.Build.0 = Release|Any CPU
147+
{D747780A-7C44-4714-AD6C-3B226A7EB2FB}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
148+
{D747780A-7C44-4714-AD6C-3B226A7EB2FB}.Release|Mixed Platforms.Build.0 = Release|Any CPU
149+
{D747780A-7C44-4714-AD6C-3B226A7EB2FB}.Release|x86.ActiveCfg = Release|Any CPU
150+
{D747780A-7C44-4714-AD6C-3B226A7EB2FB}.Release|x86.Build.0 = Release|Any CPU
151+
{2BE313F5-3ED6-4F85-ACDD-AA8F96409E91}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
152+
{2BE313F5-3ED6-4F85-ACDD-AA8F96409E91}.Debug|Any CPU.Build.0 = Debug|Any CPU
153+
{2BE313F5-3ED6-4F85-ACDD-AA8F96409E91}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
154+
{2BE313F5-3ED6-4F85-ACDD-AA8F96409E91}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
155+
{2BE313F5-3ED6-4F85-ACDD-AA8F96409E91}.Debug|x86.ActiveCfg = Debug|Any CPU
156+
{2BE313F5-3ED6-4F85-ACDD-AA8F96409E91}.Debug|x86.Build.0 = Debug|Any CPU
157+
{2BE313F5-3ED6-4F85-ACDD-AA8F96409E91}.Release|Any CPU.ActiveCfg = Release|Any CPU
158+
{2BE313F5-3ED6-4F85-ACDD-AA8F96409E91}.Release|Any CPU.Build.0 = Release|Any CPU
159+
{2BE313F5-3ED6-4F85-ACDD-AA8F96409E91}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
160+
{2BE313F5-3ED6-4F85-ACDD-AA8F96409E91}.Release|Mixed Platforms.Build.0 = Release|Any CPU
161+
{2BE313F5-3ED6-4F85-ACDD-AA8F96409E91}.Release|x86.ActiveCfg = Release|Any CPU
162+
{2BE313F5-3ED6-4F85-ACDD-AA8F96409E91}.Release|x86.Build.0 = Release|Any CPU
163+
{5D7B7984-542F-4DEA-8C2F-EBE44E6AE03D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
164+
{5D7B7984-542F-4DEA-8C2F-EBE44E6AE03D}.Debug|Any CPU.Build.0 = Debug|Any CPU
165+
{5D7B7984-542F-4DEA-8C2F-EBE44E6AE03D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
166+
{5D7B7984-542F-4DEA-8C2F-EBE44E6AE03D}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
167+
{5D7B7984-542F-4DEA-8C2F-EBE44E6AE03D}.Debug|x86.ActiveCfg = Debug|Any CPU
168+
{5D7B7984-542F-4DEA-8C2F-EBE44E6AE03D}.Debug|x86.Build.0 = Debug|Any CPU
169+
{5D7B7984-542F-4DEA-8C2F-EBE44E6AE03D}.Release|Any CPU.ActiveCfg = Release|Any CPU
170+
{5D7B7984-542F-4DEA-8C2F-EBE44E6AE03D}.Release|Any CPU.Build.0 = Release|Any CPU
171+
{5D7B7984-542F-4DEA-8C2F-EBE44E6AE03D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
172+
{5D7B7984-542F-4DEA-8C2F-EBE44E6AE03D}.Release|Mixed Platforms.Build.0 = Release|Any CPU
173+
{5D7B7984-542F-4DEA-8C2F-EBE44E6AE03D}.Release|x86.ActiveCfg = Release|Any CPU
174+
{5D7B7984-542F-4DEA-8C2F-EBE44E6AE03D}.Release|x86.Build.0 = Release|Any CPU
133175
EndGlobalSection
134176
GlobalSection(SolutionProperties) = preSolution
135177
HideSolutionNode = FALSE
@@ -144,5 +186,8 @@ Global
144186
{4490894C-3572-4E63-86F1-EE5105CE8A06} = {0F647068-6602-4E24-B1DC-8ED91481A50A}
145187
{6A74C6EA-B241-4D6B-BCE4-BF89EC1D2475} = {0F647068-6602-4E24-B1DC-8ED91481A50A}
146188
{5608E828-DD54-4E2A-B73C-FC22268BE797} = {0F647068-6602-4E24-B1DC-8ED91481A50A}
189+
{D747780A-7C44-4714-AD6C-3B226A7EB2FB} = {0F647068-6602-4E24-B1DC-8ED91481A50A}
190+
{2BE313F5-3ED6-4F85-ACDD-AA8F96409E91} = {0F647068-6602-4E24-B1DC-8ED91481A50A}
191+
{5D7B7984-542F-4DEA-8C2F-EBE44E6AE03D} = {0F647068-6602-4E24-B1DC-8ED91481A50A}
147192
EndGlobalSection
148193
EndGlobal

src/Microsoft.AspNetCore.Identity/BuilderExtensions.cs

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/Microsoft.AspNetCore.Identity/IdentityCookieOptions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ namespace Microsoft.AspNetCore.Identity
1414
public class IdentityCookieOptions
1515
{
1616
private static readonly string CookiePrefix = "Identity";
17-
private static readonly string DefaultApplicationScheme = CookiePrefix + ".Application";
17+
internal static readonly string DefaultApplicationScheme = CookiePrefix + ".Application";
1818
internal static readonly string DefaultExternalScheme = CookiePrefix + ".External";
19-
private static readonly string DefaultTwoFactorRememberMeScheme = CookiePrefix + ".TwoFactorRememberMe";
20-
private static readonly string DefaultTwoFactorUserIdScheme = CookiePrefix + ".TwoFactorUserId";
19+
internal static readonly string DefaultTwoFactorRememberMeScheme = CookiePrefix + ".TwoFactorRememberMe";
20+
internal static readonly string DefaultTwoFactorUserIdScheme = CookiePrefix + ".TwoFactorUserId";
2121

2222
/// <summary>
2323
/// Constructs a new instance of <see cref="IdentityCookieOptions"/>.

src/Microsoft.AspNetCore.Identity/IdentityMarkerService.cs

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/Microsoft.AspNetCore.Identity/IdentityServiceCollectionExtensions.cs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
5+
using Microsoft.AspNetCore.Authentication.Cookies;
56
using Microsoft.AspNetCore.Builder;
67
using Microsoft.AspNetCore.Http;
78
using Microsoft.AspNetCore.Identity;
@@ -44,17 +45,40 @@ public static IdentityBuilder AddIdentity<TUser, TRole>(
4445
where TRole : class
4546
{
4647
// Services used by identity
47-
// TODO: Need to revisit
48+
// TODO: Need to revisit how to configure the identity cookies
4849
services.AddAuthentication(options =>
4950
{
5051
// This is the Default value for ExternalCookieAuthenticationScheme
5152
options.DefaultSignInScheme = IdentityCookieOptions.DefaultExternalScheme;
5253
});
5354

55+
services.AddCookieAuthentication(IdentityCookieOptions.DefaultApplicationScheme, o =>
56+
{
57+
o.LoginPath = new PathString("/Account/Login");
58+
o.Events = new CookieAuthenticationEvents
59+
{
60+
OnValidatePrincipal = SecurityStampValidator.ValidatePrincipalAsync
61+
};
62+
});
63+
64+
services.AddCookieAuthentication(IdentityCookieOptions.DefaultExternalScheme, o =>
65+
{
66+
o.CookieName = IdentityCookieOptions.DefaultExternalScheme;
67+
o.ExpireTimeSpan = TimeSpan.FromMinutes(5);
68+
});
69+
70+
services.AddCookieAuthentication(IdentityCookieOptions.DefaultTwoFactorRememberMeScheme,
71+
o => o.CookieName = IdentityCookieOptions.DefaultTwoFactorRememberMeScheme);
72+
73+
services.AddCookieAuthentication(IdentityCookieOptions.DefaultTwoFactorUserIdScheme, o =>
74+
{
75+
o.CookieName = IdentityCookieOptions.DefaultTwoFactorUserIdScheme;
76+
o.ExpireTimeSpan = TimeSpan.FromMinutes(5);
77+
});
78+
5479
// Hosting doesn't add IHttpContextAccessor by default
5580
services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>();
5681
// Identity services
57-
services.TryAddSingleton<IdentityMarkerService>();
5882
services.TryAddScoped<IUserValidator<TUser>, UserValidator<TUser>>();
5983
services.TryAddScoped<IPasswordValidator<TUser>, PasswordValidator<TUser>>();
6084
services.TryAddScoped<IPasswordHasher<TUser>, PasswordHasher<TUser>>();

test/Microsoft.AspNetCore.Identity.InMemory.Test/Microsoft.AspNetCore.Identity.InMemory.Test.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,7 @@
2424
<PackageReference Include="xunit" Version="2.2.0-*" />
2525
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0-*" />
2626
</ItemGroup>
27+
<ItemGroup>
28+
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
29+
</ItemGroup>
2730
</Project>

0 commit comments

Comments
 (0)