diff --git a/README.md b/README.md index 8e922be..0caed0c 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ Examples: - [Passwordless.Example](examples/Passwordless.Example) — basic Passwordless.dev integration inside an ASP.NET app - [Passwordless.AspNetIdentity.Example](examples/Passwordless.AspNetIdentity.Example) — Passwordless.dev integration using ASP.NET Identity. +- [Passwordless.MultiTenancy.Example](examples/Passwordless.AspNetIdentity.Example) — Passwordless.dev integration for multi-tenant applications. ## Usage diff --git a/examples/Passwordless.MultiTenancy.Example/README.md b/examples/Passwordless.MultiTenancy.Example/README.md new file mode 100644 index 0000000..3020d81 --- /dev/null +++ b/examples/Passwordless.MultiTenancy.Example/README.md @@ -0,0 +1,50 @@ +# Requirements: +- .NET 8.0 or later +- Passwordless.dev Pro or Enterprise + +# Getting started +This example demonstrates how to use the Passwordless library in a multi-tenant environment. Where the subdomain is used +to identify the tenant. For example: + +- `republicans.passwordless.local` +- `democrats.passwordless.local` + +We can achieve this by bootstrapping the Passwordless SDK ourselves in `Program.cs` and providing the necessary +configuration. + +For a tenant `democrats` or `republicants` respectively. You would find the configuration then in your appsettings.json +file. Similarly, you can use a database or any other configuration source. + +```json +{ + "Passwordless": { + "Tenants": { + "republicans": { + "ApiSecret": "republicans:secret:00000000000000000000000000000000" + }, + "democrats": { + "ApiSecret": "democrats:secret:00000000000000000000000000000000" + } + } + } +} +``` + +1. Create entries in the hosts file: + + 127.0.0.1 republicans.passwordless.local + 127.0.0.1 democrats.passwordless.local + + These are the tenants of your own backend as an example named 'republicans' and 'democrats' + +2. Modify any tenants and their related `ApiSecret` setting in the `appsettings.json` file. + +3. Run the sample locally with .NET 8, debug if you have to step through. And visit: + + - http://republicans.passwordless.local/swagger/index.html + - http://democrats.passwordless.local/swagger/index.html + +4. Call the 'Users' endpoint from Swagger to test using your own API secrets obtained. + +You can refer to the `Passwordless.Example` project how to create your own complete backend with the Passwordless +library, as this example is a stripped-down version of it to demonstrate multi-tenancy in a simple way. \ No newline at end of file diff --git a/examples/Passwordless.MultiTenancy.Example/readme.md b/examples/Passwordless.MultiTenancy.Example/readme.md deleted file mode 100644 index e3cd6af..0000000 --- a/examples/Passwordless.MultiTenancy.Example/readme.md +++ /dev/null @@ -1,15 +0,0 @@ -1. Create entries in the hosts file: - - 127.0.0.1 republicans.passwordless.local - 127.0.0.1 democrats.passwordless.local - - These are the tenants of your own backend as an example named 'republicans' and 'democrats' - -2. Modify any tenants and their related `ApiSecret` setting in the `appsettings.json` file. - -3. Run the sample locally with .NET 8, debug if you have to step through. And visit: - - - http://republicans.passwordless.local/swagger/index.html - - http://democrats.passwordless.local/swagger/index.html - -4. Call the 'Users' endpoint to test using your own API secrets obtained. \ No newline at end of file diff --git a/global.json b/global.json index 65feccf..c87dd8a 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.303", + "version": "8.0.204", "rollForward": "latestMinor" } } \ No newline at end of file