JonPSmith / AuthPermissions.AspNetCore

This library provides extra authorization and multi-tenant features to an ASP.NET Core application.
https://www.thereformedprogrammer.net/finally-a-library-that-improves-role-authorization-in-asp-net-core/
MIT License
807 stars 161 forks source link

Improvement to `ShardingConnections.GetDatabaseInfoNamesWithTenantNamesAsync` method #39

Closed JonPSmith closed 2 years ago

JonPSmith commented 2 years ago

The GetDatabaseInfoNamesWithTenantNamesAsync method returns a list of the names of the databases found in the shardingsettings.json file, with information on what tenants are in each database. This is useful when a tenant is created or moved as you need to select a database to hold the new tenant.

In version 3.2.0 of this library the GetDatabaseInfoNamesWithTenantNamesAsync method returned a list where each entry contains:

In version 3.3.0 of this library the GetDatabaseInfoNamesWithTenantNamesAsync method a third part is provided, which means the returned information is

NOTE1: If database information name matches the ShardingDefaultDatabaseInfoName held in the AuthPermissionsOptions (default value = "Default Database") then even if there no tenants the HasOwnDb will be false, as that database contains the AuthP data, so its not applicable for sharding tenants.

This extra data is useful for a admin user, but the real reason of this change is because of the new GetDatabaseForNewTenant service / method that can automatically select a database for a new tenant.