Skip to content

Commit

Permalink
Add support for latest versions of .NET
Browse files Browse the repository at this point in the history
  • Loading branch information
giorgos07 committed Aug 20, 2022
1 parent f19411e commit 6a47fc4
Show file tree
Hide file tree
Showing 23 changed files with 237 additions and 176 deletions.
23 changes: 12 additions & 11 deletions Daarto.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29613.14
# Visual Studio Version 17
VisualStudioVersion = 17.3.32811.315
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{AE94DD8D-1626-4618-AB38-37459DEE54E0}"
EndProject
Expand All @@ -13,8 +13,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{525F
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "database", "database", "{661AB817-BF00-4B7F-88B5-9ADC84DC93A5}"
EndProject
Project("{00D1A9C2-B5F0-4AF3-8072-F6C62B433612}") = "IdentityDb", "misc\database\IdentityDb\IdentityDb.sqlproj", "{F082EB24-7AA8-4ECA-9856-6375B7AAAECB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Daarto.WebUI", "samples\Daarto.WebUI\Daarto.WebUI.csproj", "{22BA1F98-E1F9-421E-9B84-CAC07745BAEF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "data", "data", "{C413D479-154F-4A24-9984-2B0D0C0C4CC2}"
Expand All @@ -28,8 +26,11 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{B0C64769-72F4-42AE-B0E3-938FF8D1C145}"
ProjectSection(SolutionItems) = preProject
misc\docs\1.use_the_package.md = misc\docs\1.use_the_package.md
README.md = README.md
EndProjectSection
EndProject
Project("{00D1A9C2-B5F0-4AF3-8072-F6C62B433612}") = "IdentityDatabase", "misc\database\IdentityDatabase\IdentityDatabase.sqlproj", "{EFBE76EB-50AE-4C37-BA54-8ECBAB757EFC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -40,27 +41,27 @@ Global
{DD01411B-826F-4CA3-8581-8FDA9C7961AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DD01411B-826F-4CA3-8581-8FDA9C7961AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DD01411B-826F-4CA3-8581-8FDA9C7961AC}.Release|Any CPU.Build.0 = Release|Any CPU
{F082EB24-7AA8-4ECA-9856-6375B7AAAECB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F082EB24-7AA8-4ECA-9856-6375B7AAAECB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F082EB24-7AA8-4ECA-9856-6375B7AAAECB}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{F082EB24-7AA8-4ECA-9856-6375B7AAAECB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F082EB24-7AA8-4ECA-9856-6375B7AAAECB}.Release|Any CPU.Build.0 = Release|Any CPU
{F082EB24-7AA8-4ECA-9856-6375B7AAAECB}.Release|Any CPU.Deploy.0 = Release|Any CPU
{22BA1F98-E1F9-421E-9B84-CAC07745BAEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{22BA1F98-E1F9-421E-9B84-CAC07745BAEF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{22BA1F98-E1F9-421E-9B84-CAC07745BAEF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{22BA1F98-E1F9-421E-9B84-CAC07745BAEF}.Release|Any CPU.Build.0 = Release|Any CPU
{EFBE76EB-50AE-4C37-BA54-8ECBAB757EFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EFBE76EB-50AE-4C37-BA54-8ECBAB757EFC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EFBE76EB-50AE-4C37-BA54-8ECBAB757EFC}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{EFBE76EB-50AE-4C37-BA54-8ECBAB757EFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EFBE76EB-50AE-4C37-BA54-8ECBAB757EFC}.Release|Any CPU.Build.0 = Release|Any CPU
{EFBE76EB-50AE-4C37-BA54-8ECBAB757EFC}.Release|Any CPU.Deploy.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{DD01411B-826F-4CA3-8581-8FDA9C7961AC} = {AE94DD8D-1626-4618-AB38-37459DEE54E0}
{661AB817-BF00-4B7F-88B5-9ADC84DC93A5} = {AAE1B832-6032-4C5C-8154-F6775CC051F8}
{F082EB24-7AA8-4ECA-9856-6375B7AAAECB} = {661AB817-BF00-4B7F-88B5-9ADC84DC93A5}
{22BA1F98-E1F9-421E-9B84-CAC07745BAEF} = {525F9EE4-17EB-4E98-A775-C28282BC2962}
{C413D479-154F-4A24-9984-2B0D0C0C4CC2} = {AAE1B832-6032-4C5C-8154-F6775CC051F8}
{B0C64769-72F4-42AE-B0E3-938FF8D1C145} = {AAE1B832-6032-4C5C-8154-F6775CC051F8}
{EFBE76EB-50AE-4C37-BA54-8ECBAB757EFC} = {661AB817-BF00-4B7F-88B5-9ADC84DC93A5}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {78AE28B8-138A-401A-B79E-457DC5EFB188}
Expand Down
2 changes: 1 addition & 1 deletion misc/data/AspNetUsersData.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
INSERT INTO [dbo].[AspNetUsers] (Id, UserName, NormalizedUserName, Email, NormalizedEmail, EmailConfirmed, PasswordHash, SecurityStamp, ConcurrencyStamp, PhoneNumber, PhoneNumberConfirmed, TwoFactorEnabled, LockoutEnabled, AccessFailedCount) VALUES ('53ba34ce-96f8-452f-a714-0033136c66ee', '[email protected]', '[email protected]', '[email protected]', '[email protected]', 1, 'AQAAAAEAACcQAAAAEFKjcOnLHrAhew3z9YUjO/vGiExMDrNi54ZyUKACsW8rn1vDTleOUvJeNoEG3JU4fQ==', '76b51311-5cd0-49c2-9e19-8c82403cc117', '816087c4-46b4-4bb2-9923-6ba5dfe63832', '+30 6981908600', 1, 0, 0, 0);
INSERT INTO [dbo].[AspNetUsers] (Id, UserName, NormalizedUserName, Email, NormalizedEmail, EmailConfirmed, PasswordHash, SecurityStamp, ConcurrencyStamp, PhoneNumber, PhoneNumberConfirmed, TwoFactorEnabled, LockoutEnabled, AccessFailedCount) VALUES ('53ba34ce-96f8-452f-a714-0033136c66ee', '[email protected]', '[email protected]', '[email protected]', '[email protected]', 1, 'AQAAAAEAACcQAAAAEKRm/fJQk3xhqIv7O0IyPyiPJ+W5du3Io15fIcI59hfUv1DTmDid3RhgzdJVzARpQg==', '76b51311-5cd0-49c2-9e19-8c82403cc117', '816087c4-46b4-4bb2-9923-6ba5dfe63832', '+30 6981908600', 1, 0, 0, 0);
INSERT INTO [dbo].[AspNetUsers] (Id, UserName, NormalizedUserName, Email, NormalizedEmail, EmailConfirmed, SecurityStamp, ConcurrencyStamp, PhoneNumber, PhoneNumberConfirmed, TwoFactorEnabled, LockoutEnabled, AccessFailedCount) VALUES ('634963b4-a2d0-4160-ad84-c088ade8dbd9', '[email protected]', '[email protected]', '[email protected]', '[email protected]', 1, '9db08d96-5f13-4a2e-af12-07106d2a0123', '992c1c2c-5e19-4911-a1ac-47819879929a', '+81 (831) 990-1658', 1, 1, 1, 0);
INSERT INTO [dbo].[AspNetUsers] (Id, UserName, NormalizedUserName, Email, NormalizedEmail, EmailConfirmed, SecurityStamp, ConcurrencyStamp, PhoneNumber, PhoneNumberConfirmed, TwoFactorEnabled, LockoutEnabled, AccessFailedCount) VALUES ('22ddf8d1-876f-413b-b9c8-b680ae87d23a', '[email protected]', '[email protected]', '[email protected]', '[email protected]', 0, 'ca240a34-7c09-48a3-8b6b-d0f1022db534', '7c61d4b4-a2fd-4dd2-a6bb-67de5a071394', '+263 (267) 874-0846', 1, 1, 1, 0);
INSERT INTO [dbo].[AspNetUsers] (Id, UserName, NormalizedUserName, Email, NormalizedEmail, EmailConfirmed, SecurityStamp, ConcurrencyStamp, PhoneNumber, PhoneNumberConfirmed, TwoFactorEnabled, LockoutEnabled, AccessFailedCount) VALUES ('c9c36943-6e94-4f11-86a9-2f97b3dbe41e', '[email protected]', '[email protected]', '[email protected]', '[email protected]', 0, '24d1877e-23e4-46d0-bedc-306a7b4be534', 'c8ab5645-e670-411f-9b0b-6eca8f9fed2c', '+86 (977) 523-3451', 1, 0, 1, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<Name>IdentityDb</Name>
<Name>IdentityDatabase</Name>
<SchemaVersion>2.0</SchemaVersion>
<ProjectVersion>4.1</ProjectVersion>
<ProjectGuid>{f082eb24-7aa8-4eca-9856-6375b7aaaecb}</ProjectGuid>
<ProjectGuid>{efbe76eb-50ae-4c37-ba54-8ecbab757efc}</ProjectGuid>
<DSP>Microsoft.Data.Tools.Schema.Sql.Sql130DatabaseSchemaProvider</DSP>
<OutputType>Database</OutputType>
<RootPath>
</RootPath>
<RootNamespace>IdentityDb</RootNamespace>
<AssemblyName>IdentityDb</AssemblyName>
<RootNamespace>IdentityDatabase</RootNamespace>
<AssemblyName>IdentityDatabase</AssemblyName>
<ModelCollation>1033, CI</ModelCollation>
<DefaultFileStructure>BySchemaAndSchemaType</DefaultFileStructure>
<DeployToDatabase>True</DeployToDatabase>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<TargetLanguage>CS</TargetLanguage>
<AppDesignerFolder>Properties</AppDesignerFolder>
<SqlServerVerification>False</SqlServerVerification>
Expand Down
2 changes: 1 addition & 1 deletion samples/Daarto.WebUI/Daarto.WebUI.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<UserSecretsId>aspnet-Daarto.WebUI-0BC4D06A-1285-4595-85EA-07A68DD02CF3</UserSecretsId>
</PropertyGroup>
<ItemGroup>
Expand Down
19 changes: 8 additions & 11 deletions samples/Daarto.WebUI/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,24 @@ public Startup(IConfiguration 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) {
services.AddIdentity<IdentityUser, ExtendedIdentityRole>()
.AddDapperStores(options => {
options.AddRolesTable<ExtendedRolesTable, ExtendedIdentityRole>();
})
.AddDefaultUI()
.AddDefaultTokenProviders();
//services.AddDefaultIdentity<IdentityUser>()
// .AddDapperStores();
services.AddIdentity<IdentityUser, ExtendedIdentityRole>(options => {
options.Lockout.MaxFailedAccessAttempts = 3;
})
.AddDapperStores(options => {
options.AddRolesTable<ExtendedRolesTable, ExtendedIdentityRole>();
})
.AddDefaultUI()
.AddDefaultTokenProviders();
services.AddControllersWithViews();
services.AddRazorPages();
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment environment) {
if (environment.IsDevelopment()) {
app.UseDeveloperExceptionPage();
} else {
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
Expand Down
34 changes: 22 additions & 12 deletions src/AspNetCore.Identity.Dapper/AspNetCore.Identity.Dapper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,40 @@
<AssemblyName>AspNetCore.Identity.Dapper</AssemblyName>
<AssemblyTitle>AspNetCore.Identity.Dapper</AssemblyTitle>
<Authors>Georgios Manoltzas</Authors>
<Copyright>Copyright (c) 2018 - 2019 Georgios Manoltzas</Copyright>
<Copyright>Copyright (c) 2018 - 2022 Georgios Manoltzas</Copyright>
<Description>Dapper implementation of ASP.NET Core Identity stores.</Description>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TargetFrameworks>netstandard2.1;netcoreapp3.1</TargetFrameworks>
<VersionPrefix>3.1.1</VersionPrefix>
<TargetFrameworks>netstandard2.1;net5.0;net6.0;</TargetFrameworks>
<VersionPrefix>6.0.0</VersionPrefix>
</PropertyGroup>
<PropertyGroup Label="Package">
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>AspNetCore.Identity.DapperOrm</PackageId>
<PackageTags>AspNetCore;Dapper;Identity</PackageTags>
<PackageReleaseNotes>Fixes issue #14.</PackageReleaseNotes>
<PackageProjectUrl>https://github.com/giorgos07/Daarto/tree/master/src/AspNetCore.Identity.Dapper</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/giorgos07/Daarto/tree/master/src/AspNetCore.Identity.Dapper</PackageProjectUrl>
<PackageReleaseNotes>Fixes issue #14.</PackageReleaseNotes>
<PackageTags>AspNetCore;Dapper;Identity</PackageTags>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/giorgos07/Daarto/tree/master/src/AspNetCore.Identity.Dapper</RepositoryUrl>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<UserSecretsId>ea4ca2df-aa2d-4174-8f13-b1e594019d86</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="3.1.4" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="Dapper" Version="2.0.35" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.1" />
<PackageReference Include="Dapper" Version="2.0.123" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.3" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="3.1.28" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="3.1.28" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="5.0.17" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="6.0.8" />
</ItemGroup>
</Project>
3 changes: 1 addition & 2 deletions src/AspNetCore.Identity.Dapper/Stores/RoleStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ namespace AspNetCore.Identity.Dapper
/// The persistence store for roles.
/// </summary>
/// <typeparam name="TRole">The type of the class representing a role.</typeparam>
public class RoleStore<TRole> : RoleStore<TRole, string>
where TRole : IdentityRole<string>
public class RoleStore<TRole> : RoleStore<TRole, string> where TRole : IdentityRole<string>
{
/// <summary>
/// Constructs a new instance of <see cref="RoleStore{TRole}"/>.
Expand Down
4 changes: 1 addition & 3 deletions src/AspNetCore.Identity.Dapper/Stores/UserOnlyStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ namespace AspNetCore.Identity.Dapper
/// <typeparam name="TUserClaim">The type representing a claim.</typeparam>
/// <typeparam name="TUserLogin">The type representing a user external login.</typeparam>
/// <typeparam name="TUserToken">The type representing a user token.</typeparam>
public class UserOnlyStore<TUser, TKey, TUserClaim, TUserLogin, TUserToken> :
UserStoreBase<TUser, TKey, TUserClaim, TUserLogin, TUserToken>,
IProtectedUserStore<TUser>
public class UserOnlyStore<TUser, TKey, TUserClaim, TUserLogin, TUserToken> : UserStoreBase<TUser, TKey, TUserClaim, TUserLogin, TUserToken>, IProtectedUserStore<TUser>
where TUser : IdentityUser<TKey>
where TKey : IEquatable<TKey>
where TUserClaim : IdentityUserClaim<TKey>, new()
Expand Down
4 changes: 1 addition & 3 deletions src/AspNetCore.Identity.Dapper/Stores/UserStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ namespace AspNetCore.Identity.Dapper
/// <typeparam name="TUserLogin">The type representing a user external login.</typeparam>
/// <typeparam name="TUserToken">The type representing a user token.</typeparam>
/// <typeparam name="TRoleClaim">The type representing a role claim.</typeparam>
public class UserStore<TUser, TRole, TKey, TUserClaim, TUserRole, TUserLogin, TUserToken, TRoleClaim> :
UserStoreBase<TUser, TRole, TKey, TUserClaim, TUserRole, TUserLogin, TUserToken, TRoleClaim>,
IProtectedUserStore<TUser>
public class UserStore<TUser, TRole, TKey, TUserClaim, TUserRole, TUserLogin, TUserToken, TRoleClaim> : UserStoreBase<TUser, TRole, TKey, TUserClaim, TUserRole, TUserLogin, TUserToken, TRoleClaim>, IProtectedUserStore<TUser>
where TUser : IdentityUser<TKey>
where TRole : IdentityRole<TKey>
where TKey : IEquatable<TKey>
Expand Down
12 changes: 6 additions & 6 deletions src/AspNetCore.Identity.Dapper/Tables/RoleClaimsTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ namespace AspNetCore.Identity.Dapper
/// </summary>
/// <typeparam name="TKey">The type of the primary key for a role.</typeparam>
/// <typeparam name="TRoleClaim">The type of the class representing a role claim.</typeparam>
public class RoleClaimsTable<TKey, TRoleClaim> :
IdentityTable,
IRoleClaimsTable<TKey, TRoleClaim>
public class RoleClaimsTable<TKey, TRoleClaim> : IdentityTable, IRoleClaimsTable<TKey, TRoleClaim>
where TKey : IEquatable<TKey>
where TRoleClaim : IdentityRoleClaim<TKey>, new()
{
Expand All @@ -26,9 +24,11 @@ public RoleClaimsTable(IDbConnectionFactory dbConnectionFactory) : base(dbConnec

/// <inheritdoc/>
public virtual async Task<IEnumerable<TRoleClaim>> GetClaimsAsync(TKey roleId) {
const string sql = "SELECT * " +
"FROM [dbo].[AspNetRoleClaims] " +
"WHERE [RoleId] = @RoleId;";
const string sql = @"
SELECT *
FROM [dbo].[AspNetRoleClaims]
WHERE [RoleId] = @RoleId;
";
var roleClaims = await DbConnection.QueryAsync<TRoleClaim>(sql, new { RoleId = roleId });
return roleClaims;
}
Expand Down
Loading

0 comments on commit 6a47fc4

Please sign in to comment.