h1
The Reformed Programmer
h1
@(SimpleLocalizer.LocalizeFormatted( $"List of {Model.NumBooks} books", this))
h2
How to take an ASP.NET Core web site “Down for maintenance”
h2
TL;DR; – Summary of this article
h2
Setting the scene – why did I need this feature
h2
Design aims: what database changes do I want to cover?
h2
1. Startup: Registering the services
h2
Improving the support of multiple languages in .NET applications
h2
TL;DR; – Summary of this article
h2
A brief view of how .NET localization works
h2
Super-quick explanation on the IDefaultLocalizer works
h2
The localize challenges I found and how I fixed them in my library
h2
ASP.NET Core: Three(+1) ways to refresh the claims of a logged-in user
h2
TL;DR; – Summary of this article
h2
Setting the scene – three types of dynamically updating a logged-in claims
h2
Introducing the three examples of updating a user’s claims
h2
Entity Framework Core in Action Book
h2
Using custom databases with the AuthP library – Part1: normal apps
h2
TL;DR; – Summary of this article
h2
Summary of the new features in AuthP version 5.0.0
h2
Setting the scene – how AuthP’s multi-tenant features uses databases
h2
Introducing the AuthP.CustomDatabaseExamples repo
h2
Steps in building a normal AuthP application with a custom database
h2
A pattern / library for methods that return a status, including localization
h2
TL;DR; – Summary of this article
h2
1. Introduction to the StatusGeneric library
h2
Applying an improved multiple languages library to .NET applications
h2
TL;DR; – Summary of this article
h2
Super-quick explanation on the Localize-ME library provides
h2
Setting the scene – the best places to use the Localize-ME library
h2
Comparing two AuthP multi-tenant examples to see the changes
h2
2. How to use the Localize-ME library
h2
Using the Localize-ME library in an ASP.NET Core application
h2
How to turn an ASP.NET Core appsettings.json file into a fast-read database
h2
TL;DR; – Summary of this article
h2
Setting the scene – why did I use an appsettings.json file as a database?
h2
Steps to turn an appsettings.json file into a fast-read database
h2
A .NET distributed cache with a ~25 nanosecond read time!
h2
TL;DR; – Summary of this article
h2
Useful links to general info on caching
h2
Setting the scene – why and how I built the FileStore cache library.
h2
The four different FileStore cache interfaces
h2
Registering the distributed FileStore Cache
h2
The performance of the distributed FileStore Cache
h2
Using the distributed FileStore Cache
h2
Looking at the IDistributedFileStoreCacheClass version
h2
The byte[] value versions of the distributed FileStore cache
h2
Three ways to securely add new users to an application using the AuthP library
h2
TL;DR; – Summary of this article
h2
Setting the scene – how the AuthP makes it simpler to manage an application
h2
Looking at the three different ways to add a new user using the AuthP library
h2
Linking these two features to the ASP.NET Core’s authentication handlers
h2
Part6: Using sharding to build multi-tenant apps using ASP.NET Core and EF Core
h2
TL;DR; – Summary of this article
h2
Setting the scene – what is sharding and why it is useful?
h2
How I implemented sharding in version 3 of my AuthP library
h3
2. Implement a hybrid multi-tenant application.
h3
1. Implement a sharding-only multi-tenant application
h3
1. Define a json file to act as a database
h3
2. Make sure the database json file isn’t overwritten
h3
3. Register the database json file on startup
h3
5. Other things to consider when moving a tenant database
h3
Real-world examples of using the StatusGeneric library
h3
4. Extra: Using IClaimTransformation to update the user’s claims
h3
4. Write to the database json file within a distributed lock
h3
5. Use IOptionsSnapshot to read the database json file
h3
1. Setting up the .NET localization
h3
2. Setting up the Localize-ME services
h3
3. Adding your resource files and TResource classes
h3
4. Getting an instance of the SimpleLocalizer
h3
5. Getting an instance of the DefaultLocalizer
h3
6. Using the SimpleLocalizer service
h3
How the StatusGenericLocalizer is different from the StatusGeneric?
h3
Real-world examples of using the Localize-ME library
h3
1. The SimpleLocalizer service is good for using in Razor pages etc.
h3
2. The DefaultLocalizer service is better on large localizations with backend projects
h3
Things that the Localize-ME library doesn’t provide
h3
The returned status: IStatusGeneric and IStatusGeneric
h3
How to use the StatusGeneric library in your code
h3
Different ways to add errors to the status
h3
1. Create a migration of the AuthPermissionsDbContext for your custom database
h3
2. Extension method to register your custom database
h3
3. Other, non-AuthP things you need to think about
h3
1. Update user claims via cookie event: Cookie authentication only
h3
1. I didn’t want to turn all the messages / errors into just a localize key
h3
2. I wanted a NuGet that works without having to setup the .NET localization
h3
3. I didn’t like .NET’s localization’s handling of missing resource files / entries
h3
4. I wanted a better format for the localise key to help creating unique strings
h3
5. I wanted to unit test without setting up localization.
h3
6. I wanted to check the localized messages with their localize key
h3
7. Tip: Use Excel (or other app) to setup the data for the resource files.
h3
2. Create a Controller / web APIs to handle the “down for maintenance”
h3
3. Using the ISetRemoveStatus service to set / remove a “down” state
h3
4. Understanding the “down for maintenance” middleware
h3
7. Using the DefaultLocalizer service
h3
8. How to unit test your localized code
h3
2. Replace a user claim on a change: JWT Token and cookie authentication
h3
3. On-demand add a new claim in middleware: JWT Token and cookie
h4
3.1 The middleware which adds a new claim
h4
3.2. The event code to detect the change of a user’s email
h4
2.1 The event code to detect the database changes
h4
2.2. The middleware which updates the HTTP User outdated claim
h4
8a. Logging Localize-ME localization during unit testing
h4
STAGE 1: Allowed URLs get through
h4
STAGE 2: Handle AppDown
h4
STAGE 3: Handle Tenant “down”
h4
1.3 The event code to detect the database changes
h4
1.2 The GlobalChangeTimeService class
h4
1.3 The event code called by cookie’s OnValidatePrincipal
h4
1. Using multiple checks to return all the errors to the user
h4
2. Combining errors from multiple statuses
h4
3a. Example3.InvoiceCode -> CustomDatabase1.InvoiceCode
h4
3.c. Example3.MvcWebApp.IndividualAccounts -> CustomDatabase1.WebApp
h4
5.1. Updating the tenant user’s DataKey claims on a move
h4
5.2. An internal hierarchical move needs to “down” two parts of the tenant data
h4
5.3. The “admin access to tenant” data feature needs extra code in the middleware
h4
3.1 Register the database json file to the ASP.NET Core’s Configuration
h4
3.2 Register your IOptions access via the Configure service
h4
The Pros of the “Sync users” approach
h4
The Cons of the “Sync users” approach
h4
The Pros of the “invite a user” approach
h4
The Cons of the “invite a user” approach
h4
3. Multi-tenant: “sign up / versioning” to create a new tenant
h4
The Pros of the “sign up / versioning” approach
h4
The Cons of the “sign up / versioning” approach
h4
2. Hold information of the tenant and its users in admin database
h4
3. When a user logs in, then add a ConnectionName claim to their claims
h4
4. Provide a service to convert the user’s ConnectionName claim to a database connection
h4
5. Provide the connection string to the application’s DbContext
h4
6. Use EF Core’s SetConnectionString method to set the database connection
h4
7. Migrate a database if not used before
h4
1. Decide on how to manage databases, especially in production
h4
1 Decide on how to manage databases, especially in production
h4
2. Hold extra information of the tenant and its users in admin database
h4
3. When a user logs in, then add a ConnectionName and DataKey claim to their claims
h4
4. Provide a service to convert the user’s ConnectionName claim to a database connection
h4
5. Provide the connection string and DataKey to the application’s DbContext
h4
6. Use EF Core’s SetConnectionString method to set the database connection and DataKey
h4
7. Migrate the tenant database if not used before
h4
8. Extra features available in a hybrid design.
h5
6.1. The query filter is “turned off”
h5
6.2. It stops the setting of the DataKey
h5
1a. How to define the database servers
h5
1b. How to define the databases