-
Notifications
You must be signed in to change notification settings - Fork 162
Version 1 Limitations
Version 1 of the AuthP library has some limitations around an ASP.NET Core application that has run multiple instances, known as scale out. The problem with multiple instances starting up at the same time you cannot setup a database or similar on startup, because each instance will try to apply the database multiple times, which won't work.
NOTE: Version 2 of AuthP library will contain a feature that can get around these issues via a "run each in turn" library.
The most important issue is migrating the AuthP's database on startup, but I have listed all possible methods / settings that won't work (most of these are only used in the example applications in the AuthP repo).
The problem is if you run multiple EF Core's migrations running at the same time, then they will fail. Therefore you cannot use AuthP's SetupAspNetCoreAndDatabase()
extension, which applies a migration during the startup of the ASP.NET Core application.
The solution is to:
- Manually migrate the AuthP's database, either by:
- Use EF Core's
dotnet ef database update
command to migrate the database - Obtaining the SQL migration script via EF Core's
dotnet ef migrations script
command and applying it to the database - Creating a stand-alone application that accesses the AuthP library (you can obtain the
AuthPermissionsDbContext
from the services and then call thecontext.Database.Migrate
method. - Or many other ways...
- Use EF Core's
- Replace the
SetupAspNetCoreAndDatabase()
with theSetupAspNetCorePart()
extension method in the registering of the AuthP library in theStartup
class. This will ensure that AuthP does not try to migrate the AuthP database.
The AuthP's AddSuperUserToIndividualAccounts()
method is a quick way to add an admin user, but the method might throw an exception on startup due to multiple calls clashing.
The examples applications in the AuthP's repo use Bulk Loading to set up the AuthP's Roles, Tenants and Users.
This isn't a big issue in a real application, but if you do need lots of Roles, Tenants or Users added to your application you could create a method / page that can be called manually by an admin user once the application is running.
- Intro to multi-tenants (ASP.NET video)
- Articles in date order:
- 0. Improved Roles/Permissions
- 1. Setting up the database
- 2. Admin: adding users and tenants
- 3. Versioning your app
- 4. Hierarchical multi-tenant
- 5. Advanced technique with claims
- 6. Sharding multi-tenant setup
- 7. Three ways to add new users
- 8. The design of the sharding data
- 9. Down for maintenance article
- 10: Three ways to refresh claims
- 11. Features of Multilingual service
- 12. Custom databases - Part1
- Videos (old)
- Authentication explained
- Permissions explained
- Roles explained
- AuthUser explained
- Multi tenant explained
- Sharding explained
- How AuthP handles sharding
- How AuthP handles errors
- Languages & cultures explained
- JWT Token refresh explained
- Setup Permissions
- Setup Authentication
- Startup code
- Setup the custom database feature
- JWT Token configuration
- Multi tenant configuration
- Using Permissions
- Using JWT Tokens
- Creating a multi-tenant app
- Supporting multiple languages
- Unit Test your AuthP app