Skip to content

Commit 5279c04

Browse files
committed
Version 9.0.0
1 parent c03c8bd commit 5279c04

File tree

10 files changed

+126
-63
lines changed

10 files changed

+126
-63
lines changed

AuthPermissions.AspNetCore.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
2020
ReleaseNotes.md = ReleaseNotes.md
2121
UpdateToVersion6.md = UpdateToVersion6.md
2222
UpdateToVersion620.md = UpdateToVersion620.md
23+
UpdateToVersion9.md = UpdateToVersion9.md
2324
EndProjectSection
2425
EndProject
2526
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example2.WebApiWithToken.IndividualAccounts", "Example2.WebApiWithToken.IndividualAccounts\Example2.WebApiWithToken.IndividualAccounts.csproj", "{E2667176-A75B-4182-94AF-43D8F0CF989A}"

AuthPermissions.AspNetCore/CreateNuGetRelease.nuspec

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,66 +2,66 @@
22
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
33
<metadata>
44
<id>AuthPermissions.AspNetCore</id>
5-
<version>8.1.0</version>
5+
<version>9.0.0</version>
66
<authors>Jon P Smith</authors>
77
<product>AuthPermissions.AspNetCore</product>
88
<copyright>Copyright (c) 2021 Jon P Smith</copyright>
99
<description>Provides extra authorization and multi-tenant features to an ASP.NET Core application.</description>
1010
<releaseNotes>
11-
- Code to recreate the ShardingEntries if the FileStore Cache is deleted - see issue #115
12-
- Updates vulnerable NuGets Microsoft.Identity.Client and System.Text.Json
11+
- Updated to .NET 9 version
12+
- BREAKING CHANGE: EF Core 9 added extra migration checks - see UpdateToVersion9.md to update your multi-tenant DbContext.
1313
</releaseNotes>
1414
<license type="expression">MIT</license>
1515
<projectUrl>https://github.com/JonPSmith/AuthPermissions.AspNetCore</projectUrl>
1616
<icon>images\AuthPermissionsAspNetCoreNuGetIcon.png</icon>
1717
<tags>ASP.NET Core, Entity Framework Core</tags>
1818
<dependencies>
19-
<group targetFramework="net8.0">
19+
<group targetFramework="net9.0">
2020
<dependency id="GenericServices.StatusGeneric" version="1.2.0" />
21-
<dependency id="Microsoft.AspNetCore.Identity.EntityFrameworkCore" version="8.0.0" />
22-
<dependency id="Microsoft.Data.Sqlite.Core" version="8.0.2" />
23-
<dependency id="Microsoft.EntityFrameworkCore" version="8.0.2" />
24-
<dependency id="Microsoft.EntityFrameworkCore.InMemory" version="8.0.2" />
25-
<dependency id="Microsoft.EntityFrameworkCore.Sqlite" version="8.0.2" />
26-
<dependency id="Microsoft.EntityFrameworkCore.SqlServer" version="8.0.2" />
27-
<dependency id="Npgsql.EntityFrameworkCore.PostgreSQL" version="8.0.2" />
28-
<dependency id="Microsoft.EntityFrameworkCore.Tools" version="8.0.2" />
29-
<dependency id="Microsoft.Extensions.Hosting" version="8.0.0" />
21+
<dependency id="Microsoft.AspNetCore.Identity.EntityFrameworkCore" version="9.0.0" />
22+
<dependency id="Microsoft.Data.Sqlite.Core" version="9.0.0" />
23+
<dependency id="Microsoft.EntityFrameworkCore" version="9.0.0" />
24+
<dependency id="Microsoft.EntityFrameworkCore.InMemory" version="9.0.0" />
25+
<dependency id="Microsoft.EntityFrameworkCore.Sqlite" version="9.0.0" />
26+
<dependency id="Microsoft.EntityFrameworkCore.SqlServer" version="9.0.0" />
27+
<dependency id="Npgsql.EntityFrameworkCore.PostgreSQL" version="9.0.1" />
28+
<dependency id="Microsoft.EntityFrameworkCore.Tools" version="9.0.0" />
29+
<dependency id="Microsoft.Extensions.Hosting" version="9.0.0" />
3030
<dependency id="Net.RunMethodsSequentially" version="2.0.1" />
31-
<dependency id="Net.LocalizeMessagesAndErrors" version="8.0.0" />
32-
<dependency id="Microsoft.AspNetCore.Authentication.OpenIdConnect" version="8.0.0" />
33-
<dependency id="Microsoft.AspNetCore.Authorization" version="8.0.0" />
34-
<dependency id="Microsoft.IdentityModel.JsonWebTokens" version="7.5.1" />
31+
<dependency id="Net.LocalizeMessagesAndErrors" version="9.0.0" />
32+
<dependency id="Microsoft.AspNetCore.Authentication.OpenIdConnect" version="9.0.0" />
33+
<dependency id="Microsoft.AspNetCore.Authorization" version="9.0.0" />
34+
<dependency id="Microsoft.IdentityModel.JsonWebTokens" version="8.2.1" />
3535
<dependency id="Net.DistributedFileStoreCache" version="2.0.0" />
36-
<dependency id="System.IdentityModel.Tokens.Jwt" version="7.1.2" />
37-
<dependency id="EntityFrameworkCore.Exceptions.PostgreSQL" version="8.1.2" />
38-
<dependency id="EntityFrameworkCore.Exceptions.Sqlite" version="8.1.2" />
39-
<dependency id="EntityFrameworkCore.Exceptions.SqlServer" version="8.0.0.2" />
40-
<dependency id="Microsoft.EntityFrameworkCore.Design" version="8.0.2" />
41-
<dependency id="Microsoft.Extensions.Localization.Abstractions" version="8.0.0" />
42-
<dependency id="DistributedLock" version="2.4.0" />
36+
<dependency id="System.IdentityModel.Tokens.Jwt" version="8.2.1" />
37+
<dependency id="EntityFrameworkCore.Exceptions.PostgreSQL" version="8.1.3" />
38+
<dependency id="EntityFrameworkCore.Exceptions.Sqlite" version="8.1.3" />
39+
<dependency id="EntityFrameworkCore.Exceptions.SqlServer" version="8.1.3" />
40+
<dependency id="Microsoft.EntityFrameworkCore.Design" version="9.0.0" />
41+
<dependency id="Microsoft.Extensions.Localization.Abstractions" version="9.0.0" />
42+
<dependency id="DistributedLock" version="2.5.0" />
4343
<dependency id="Microsoft.Graph" version="4.54.0" />
4444
</group>
4545
</dependencies>
4646
</metadata>
4747
<files>
48-
<file src="..\AuthPermissions\bin\Release\net8.0\AuthPermissions.dll" target="lib\net8.0" />
49-
<file src="..\AuthPermissions\bin\Release\net8.0\AuthPermissions.xml" target="lib\net8.0" />
50-
<file src="..\AuthPermissions\bin\Release\net8.0\AuthPermissions.pdb" target="lib\net8.0" />
51-
<file src="..\AuthPermissions.AspNetCore\bin\Release\net8.0\AuthPermissions.AspNetCore.dll" target="lib\net8.0" />
52-
<file src="..\AuthPermissions.AspNetCore\bin\Release\net8.0\AuthPermissions.AspNetCore.xml" target="lib\net8.0" />
53-
<file src="..\AuthPermissions.AspNetCore\bin\Release\net8.0\AuthPermissions.AspNetCore.pdb" target="lib\net8.0" />
54-
<file src="..\AuthPermissions.BaseCode\bin\Release\net8.0\AuthPermissions.BaseCode.dll" target="lib\net8.0" />
55-
<file src="..\AuthPermissions.BaseCode\bin\Release\net8.0\AuthPermissions.BaseCode.xml" target="lib\net8.0" />
56-
<file src="..\AuthPermissions.BaseCode\bin\Release\net8.0\AuthPermissions.BaseCode.pdb" target="lib\net8.0" />
57-
<file src="..\AuthPermissions.PostgreSql\bin\Release\net8.0\AuthPermissions.PostgreSql.dll" target="lib\net8.0" />
58-
<file src="..\AuthPermissions.PostgreSql\bin\Release\net8.0\AuthPermissions.PostgreSql.xml" target="lib\net8.0" />
59-
<file src="..\AuthPermissions.PostgreSql\bin\Release\net8.0\AuthPermissions.PostgreSql.pdb" target="lib\net8.0" />
60-
<file src="..\AuthPermissions.SqlServer\bin\Release\net8.0\AuthPermissions.SqlServer.dll" target="lib\net8.0" />
61-
<file src="..\AuthPermissions.SqlServer\bin\Release\net8.0\AuthPermissions.SqlServer.pdb" target="lib\net8.0" />
62-
<file src="..\AuthPermissions.SupportCode\bin\Release\net8.0\AuthPermissions.SupportCode.dll" target="lib\net8.0" />
63-
<file src="..\AuthPermissions.SupportCode\bin\Release\net8.0\AuthPermissions.SupportCode.xml" target="lib\net8.0" />
64-
<file src="..\AuthPermissions.SupportCode\bin\Release\net8.0\AuthPermissions.SupportCode.pdb" target="lib\net8.0" />
48+
<file src="..\AuthPermissions\bin\Release\net9.0\AuthPermissions.dll" target="lib\net9.0" />
49+
<file src="..\AuthPermissions\bin\Release\net9.0\AuthPermissions.xml" target="lib\net9.0" />
50+
<file src="..\AuthPermissions\bin\Release\net9.0\AuthPermissions.pdb" target="lib\net9.0" />
51+
<file src="..\AuthPermissions.AspNetCore\bin\Release\net9.0\AuthPermissions.AspNetCore.dll" target="lib\net9.0" />
52+
<file src="..\AuthPermissions.AspNetCore\bin\Release\net9.0\AuthPermissions.AspNetCore.xml" target="lib\net9.0" />
53+
<file src="..\AuthPermissions.AspNetCore\bin\Release\net9.0\AuthPermissions.AspNetCore.pdb" target="lib\net9.0" />
54+
<file src="..\AuthPermissions.BaseCode\bin\Release\net9.0\AuthPermissions.BaseCode.dll" target="lib\net9.0" />
55+
<file src="..\AuthPermissions.BaseCode\bin\Release\net9.0\AuthPermissions.BaseCode.xml" target="lib\net9.0" />
56+
<file src="..\AuthPermissions.BaseCode\bin\Release\net9.0\AuthPermissions.BaseCode.pdb" target="lib\net9.0" />
57+
<file src="..\AuthPermissions.PostgreSql\bin\Release\net9.0\AuthPermissions.PostgreSql.dll" target="lib\net9.0" />
58+
<file src="..\AuthPermissions.PostgreSql\bin\Release\net9.0\AuthPermissions.PostgreSql.xml" target="lib\net9.0" />
59+
<file src="..\AuthPermissions.PostgreSql\bin\Release\net9.0\AuthPermissions.PostgreSql.pdb" target="lib\net9.0" />
60+
<file src="..\AuthPermissions.SqlServer\bin\Release\net9.0\AuthPermissions.SqlServer.dll" target="lib\net9.0" />
61+
<file src="..\AuthPermissions.SqlServer\bin\Release\net9.0\AuthPermissions.SqlServer.pdb" target="lib\net9.0" />
62+
<file src="..\AuthPermissions.SupportCode\bin\Release\net9.0\AuthPermissions.SupportCode.dll" target="lib\net9.0" />
63+
<file src="..\AuthPermissions.SupportCode\bin\Release\net9.0\AuthPermissions.SupportCode.xml" target="lib\net9.0" />
64+
<file src="..\AuthPermissions.SupportCode\bin\Release\net9.0\AuthPermissions.SupportCode.pdb" target="lib\net9.0" />
6565
<file src="..\AuthPermissions.AspNetCore\images\AuthPermissionsAspNetCoreNuGetIcon.png" target="images\" />
6666
</files>
6767
</package>

AuthPermissions.AspNetCore/MultiProjPack.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
<copyright>Copyright (c) 2021 Jon P Smith</copyright>
1111
<description>Provides extra authorization and multi-tenant features to an ASP.NET Core application.</description>
1212
<releaseNotes>
13-
- .NET 9 version
13+
- Updated to .NET 9 version
14+
- BREAKING CHANGE: EF Core 9 added extra migration checks - see UpdateToVersion9.md to update your multi-tenant DbContext.
1415
</releaseNotes>
1516
<license type="expression">MIT</license>
1617
<projectUrl>https://github.com/JonPSmith/AuthPermissions.AspNetCore</projectUrl>

AuthPermissions.BaseCode/DataLayer/EfCode/AuthPermissionsDbContext.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,14 @@ public AuthPermissionsDbContext(DbContextOptions<AuthPermissionsDbContext> optio
3636
_customConfiguration = customConfiguration;
3737
}
3838

39+
/// <summary>
40+
/// This is needed for EF Core 9 and above when building a multi-tenant application.
41+
/// This allows you to add more than one migration on this database
42+
/// </summary>
43+
/// <param name="optionsBuilder"></param>
3944
protected override void OnConfiguring(
4045
DbContextOptionsBuilder optionsBuilder)
4146
{
42-
//This allows you to add more that one migration on this database
4347
optionsBuilder.ConfigureWarnings(x => x.Ignore(RelationalEventId.PendingModelChangesWarning));
4448
base.OnConfiguring(optionsBuilder);
4549
}

Example3.InvoiceCode/EfCoreCode/InvoicesDbContext.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,19 @@ public InvoicesDbContext(DbContextOptions<InvoicesDbContext> options, IGetDataKe
2121
: base(options)
2222
{
2323
// The DataKey is null when: no one is logged in, its a background service, or user hasn't got an assigned tenant
24-
// In these cases its best to set the data key that doesn't match any possible DataKey
24+
// In these cases it's best to set the data key that doesn't match any possible DataKey
2525
DataKey = dataKeyFilter?.DataKey ?? "Bad key";
2626
}
2727

28+
/// <summary>
29+
/// This is needed for EF Core 9 and above when building a multi-tenant application.
30+
/// This allows you to add more than one migration on this database
31+
/// NOTE: You don't need to add this code if you are building a Sharding-Only type multi-tenant.
32+
/// </summary>
33+
/// <param name="optionsBuilder"></param>
2834
protected override void OnConfiguring(
2935
DbContextOptionsBuilder optionsBuilder)
3036
{
31-
//This allows you to add more that one migration on this database
3237
optionsBuilder.ConfigureWarnings(x => x.Ignore(RelationalEventId.PendingModelChangesWarning));
3338
base.OnConfiguring(optionsBuilder);
3439
}

Example3.MvcWebApp.IndividualAccounts/Data/ApplicationDbContext.cs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,23 @@
22
using Microsoft.EntityFrameworkCore;
33
using Microsoft.EntityFrameworkCore.Diagnostics;
44

5-
namespace Example3.MvcWebApp.IndividualAccounts.Data
5+
namespace Example3.MvcWebApp.IndividualAccounts.Data;
6+
7+
public class ApplicationDbContext : IdentityDbContext
68
{
7-
public class ApplicationDbContext : IdentityDbContext
9+
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
10+
: base(options) {}
11+
12+
/// <summary>
13+
/// This is needed for EF Core 9 and above when building a multi-tenant application.
14+
/// This allows you to add more than one migration on this database
15+
/// NOTE: You don't need to add this code if you are building a Sharding-Only type multi-tenant.
16+
/// </summary>
17+
/// <param name="optionsBuilder"></param>
18+
protected override void OnConfiguring(
19+
DbContextOptionsBuilder optionsBuilder)
820
{
9-
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
10-
: base(options) {}
11-
12-
protected override void OnConfiguring(
13-
DbContextOptionsBuilder optionsBuilder)
14-
{
15-
//This allows you to add more that one migration on this database
16-
optionsBuilder.ConfigureWarnings(x => x.Ignore(RelationalEventId.PendingModelChangesWarning));
17-
base.OnConfiguring(optionsBuilder);
18-
}
21+
optionsBuilder.ConfigureWarnings(x => x.Ignore(RelationalEventId.PendingModelChangesWarning));
22+
base.OnConfiguring(optionsBuilder);
1923
}
20-
}
24+
}

Example6.SingleLevelSharding/EfCoreCode/ShardingSingleDbContext.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,15 @@ public ShardingSingleDbContext(DbContextOptions<ShardingSingleDbContext> options
3636
Database.SetConnectionString(shardingDataKeyAndConnect.ConnectionString);
3737
}
3838

39+
/// <summary>
40+
/// This is needed for EF Core 9 and above when building a multi-tenant application.
41+
/// This allows you to add more than one migration on this database
42+
/// NOTE: You don't need to add this code if you are building a Sharding-Only type multi-tenant.
43+
/// </summary>
44+
/// <param name="optionsBuilder"></param>
3945
protected override void OnConfiguring(
4046
DbContextOptionsBuilder optionsBuilder)
4147
{
42-
//This allows you to add more that one migration on this database
4348
optionsBuilder.ConfigureWarnings(x => x.Ignore(RelationalEventId.PendingModelChangesWarning));
4449
base.OnConfiguring(optionsBuilder);
4550
}

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,16 @@ The AuthP is an open-source library under the MIT licence (and remain as a open-
1010

1111
## List of versions and which .NET framework they support
1212

13+
- Version 9.?.? supports NET 9 only (simpler to update to next NET release)
1314
- Version 8.?.? supports NET 8 only (simpler to update to next NET release)
1415
- Version 6.?.? supports NET 6, 7 and 8
1516
- Version 5.?.? supports NET 6 and 7
1617

1718
If you have already built your application using an older version, then you need to look at the following "how up update" documents
1819

20+
- For AuthPermissions.AspNetCore versions below 9 see [UpdateToVersion9.md](https://github.com/JonPSmith/AuthPermissions.AspNetCore/blob/main/UpdateToVersion9.md)
1921
- From Migrating from AuthPermissions.AspNetCore 3, 4, 5 to 6.1 see [UpdateToVersion620.md](https://github.com/JonPSmith/AuthPermissions.AspNetCore/blob/main/UpdateToVersion620.md). NOTE: you only need to do this if you are using the "Sign up for a new tenant, with versioning" (shortened to "Sign up Tenant") feature **AND** your multi-tenant uses [sharding](https://github.com/JonPSmith/AuthPermissions.AspNetCore/wiki/Sharding-explained).
2022
- From Migrating from AuthPermissions.AspNetCore 3, 4, 5 to 6.0 see [UpdateToVersion6.md](https://github.com/JonPSmith/AuthPermissions.AspNetCore/blob/main/UpdateToVersion5.md)
21-
- From Migrating from AuthPermissions.AspNetCore 2, 3 or 4.* to 5.0 see [UpdateToVersion5.md](https://github.com/JonPSmith/AuthPermissions.AspNetCore/blob/main/UpdateToVersion5.md)
22-
- From Migrating from AuthPermissions.AspNetCore 2.* to 3.0 see [UpdateToVersion3.md](https://github.com/JonPSmith/AuthPermissions.AspNetCore/blob/main/UpdateToVersion3.md)
23-
- From Migrating from AuthPermissions.AspNetCore 1.* to 1.0 see [UpdateToVersion2.md](https://github.com/JonPSmith/AuthPermissions.AspNetCore/blob/main/UpdateToVersion2.md)
2423

2524
The AuthP library also:
2625

Test/DiTestHelpers/ApplicationDbContext.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@ public class ApplicationDbContext : IdentityDbContext
1313
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
1414
: base(options) { }
1515

16+
/// <summary>
17+
/// This is needed for EF Core 9 and above when building a multi-tenant application.
18+
/// This allows you to add more than one migration on this database
19+
/// NOTE: You don't need to add this code if you are building a Sharding-Only type multi-tenant.
20+
/// </summary>
21+
/// <param name="optionsBuilder"></param>
1622
protected override void OnConfiguring(
1723
DbContextOptionsBuilder optionsBuilder)
1824
{
19-
//This allows you to add more that one migration on this database
2025
optionsBuilder.ConfigureWarnings(x => x.Ignore(RelationalEventId.PendingModelChangesWarning));
2126
base.OnConfiguring(optionsBuilder);
2227
}

UpdateToVersion9.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Updating your code from AuthPermissions.AspNetCore to EF Core 9
2+
3+
EF Core 9 has added code to ensure that migrations are executed correctly - see EF Core 9's [updated migrations](https://learn.microsoft.com/en-us/ef/core/what-is-new/ef-core-9.0/whatsnew#migrations). The AuthP library already have code to ensure that migrations are executed correctly, but one of the EF Core 9's changes is to check that only one migration is executed on a database. It does this to ensure that migrations don't clash.
4+
5+
AuthP does apply two migrations when building multi-tenant applications. This means you need to add a `OnConfiguring` the code shown to your tenant's `DbContext`. The code below comes from [Example3's tenant `DbContext`](https://github.com/JonPSmith/AuthPermissions.AspNetCore/blob/main/Example3.InvoiceCode/EfCoreCode/InvoicesDbContext.cs) - the new code for EF Core 9 is the new `OnConfiguring` method. See below.
6+
7+
```c#
8+
namespace Example3.MvcWebApp.IndividualAccounts.Data;
9+
10+
public class ApplicationDbContext : IdentityDbContext
11+
{
12+
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
13+
: base(options) {}
14+
15+
/// <summary>
16+
/// This is needed for EF Core 9 and above when building a multi-tenant application.
17+
/// This allows you to add more than one migration on this database
18+
/// NOTE: You don't need to add this code if you are building a Sharding-Only type multi-tenant.
19+
/// </summary>
20+
/// <param name="optionsBuilder"></param>
21+
protected override void OnConfiguring(
22+
DbContextOptionsBuilder optionsBuilder)
23+
{
24+
optionsBuilder.ConfigureWarnings(x =>
25+
x.Ignore(RelationalEventId.PendingModelChangesWarning));
26+
base.OnConfiguring(optionsBuilder);
27+
}
28+
29+
//other code left out...
30+
}
31+
```
32+
33+
NOTE: If you get an `InvalidOperationException` with the text shown below on startup, then you haven't added the `OnConfiguring` shown above, then you haven't added the code above.
34+
35+
```text
36+
An error was generated for warning 'Microsoft.EntityFrameworkCore.Migrations.PendingModelChangesWarning': The model for context '-your tenant context-' has pending changes. Add a new migration before updating the database. This exception can be suppressed or logged by passing event ID 'RelationalEventId.PendingModelChangesWarning' to the 'ConfigureWarnings' method in 'DbContext.OnConfiguring' or 'AddDbContext'.
37+
```
38+
39+
END

0 commit comments

Comments
 (0)