-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Midway through adding PasswordCredential authentication
- Loading branch information
1 parent
ddf8f22
commit 46c040a
Showing
250 changed files
with
10,035 additions
and
396 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Authentication | ||
|
||
* status: accepted | ||
* date: 2024-01-01 | ||
* deciders: jezzsantos | ||
|
||
# Context and Problem Statement | ||
|
||
AuthN (short for Authentication) is not to be confused with AuthZ (short for Authorization). | ||
|
||
AuthN is essentially the process of identifying an end-user given some kind of proof that they provide (common forms include usernames+passwords, pin numbers etc). Once that proof is verified, the end-user can be identified, and information about the end-user can be used downstream to authorize the user and apply rules to their use of the software. | ||
|
||
Today there are many options for integrating AuthN into a SaaS product, and each and everyone of those options represents a set of trade-offs in many things, including: | ||
|
||
* Cost | ||
* Maintainability | ||
* Complexity | ||
* Flexibility | ||
* Capability and Familiarity, | ||
* Vendor Lock-In, | ||
* Security, etc | ||
|
||
Given this is a SaaS context, for small teams, and given we are building a backend API plus a separate front end web app, we need to aim to: | ||
|
||
* Choose a decent (well-known) integration that can added easily (at low cost), | ||
* Offer reasonable flexibility (to expand to changing needs of a particular business). | ||
* The chosen solution must be customized easily, and can be easily upgraded or replaced later with other integrations. | ||
* It must be secure and multi-client friendly (e.g., web app and mobile app and machine-to-machine) when applied to a backend API (i.e. not bound to cookies). | ||
* We prefer to utilize refreshable, transparent, signed JWT tokens. | ||
* We will need it to be extensible to accommodate Single-Sign-On (SSO) scenarios. | ||
* It needs to be very secure, and we need to ship user credentials solution out of the box. | ||
|
||
Lastly, we need to introduce some minimal abstractions to make that integration easier to understand and to rip out and change later (e.g., ports and adapters). | ||
|
||
## Considered Options | ||
|
||
The options are: | ||
|
||
1. Custom Implementation | ||
2. ASP.NET Core Identity | ||
3. Auth0 | ||
4. Duende IdentityServer (https://duendesoftware.com/products/identityserver) | ||
5. OpenIddict (https://documentation.openiddict.com/) | ||
6. etc | ||
|
||
## Decision Outcome | ||
|
||
`Custom Implementation` | ||
|
||
- No additional operational costs, (unlike IdentityServer, Auth0, etc) | ||
- Can be swapped out for an implementation of IdentityServer, Auth0, Okta, or other solution. | ||
- Has decent support for most of the most common capabilities for SaaS business e.g. Transparent JWT tokens, custom claims, Single Sign On integrations, MFA, Authenticator apps, password management, etc) | ||
- Is a superior option to `ASP.NET Core Identity` since we are not limited to opaque non-JWT tokens (as they are in ANCI), and we can control the behaviour of each of the APIs, which cannot be done in ANCI. | ||
|
||
## More Information | ||
|
||
See Andrew Locks discussion on using the [ASP.NET Core Identity APIs in .NET 8.0](https://andrewlock.net/should-you-use-the-dotnet-8-identity-api-endpoints/#what-are-the-new-identity-api-endpoints-) |
15 changes: 15 additions & 0 deletions
15
docs/design-principles/0090-authentication-authorization.md.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Authentication & Authorization | ||
|
||
## Design Principles | ||
|
||
## Implementation | ||
|
||
Cookie Authentication | ||
|
||
Usually performed by a BackendForFrontend component, reverse-proxies the token hidden in the cookie, into a token passed to the backend | ||
|
||
Authorization | ||
|
||
For marked endpoints, verifies that the cookie exists. | ||
|
||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System.Reflection; | ||
using AncillaryInfrastructure.Api.Usages; | ||
using Application.Persistence.Shared; | ||
using Application.Services.Shared; | ||
using Common; | ||
using Domain.Services.Shared.DomainServices; | ||
using Infrastructure.Hosting.Common.Extensions; | ||
using Infrastructure.Persistence.Interfaces; | ||
using Infrastructure.Persistence.Shared.ApplicationServices; | ||
using Infrastructure.Shared.ApplicationServices; | ||
using Infrastructure.Web.Hosting.Common; | ||
|
||
namespace ApiHost1; | ||
|
||
/// <summary> | ||
/// Provides a module for common services of a API host | ||
/// </summary> | ||
public class ApiHostModule : ISubDomainModule | ||
{ | ||
public Assembly ApiAssembly => typeof(UsagesApi).Assembly; | ||
|
||
public Assembly DomainAssembly => null!; | ||
|
||
public Dictionary<Type, string> AggregatePrefixes => new(); | ||
|
||
public Action<ConfigurationManager, IServiceCollection> RegisterServices | ||
{ | ||
get | ||
{ | ||
return (_, services) => | ||
{ | ||
services.RegisterUnshared<IEmailMessageQueueRepository>(c => | ||
new EmailMessageQueueRepository(c.Resolve<IRecorder>(), c.ResolveForPlatform<IQueueStore>())); | ||
services.RegisterUnshared<ITokensService, TokensService>(); | ||
services.RegisterUnshared<INotificationsService, EmailNotificationsService>(); | ||
services.RegisterUnshared<IWebsiteUiService, WebsiteUiService>(); | ||
services.RegisterUnshared<IEmailQueuingService, EmailQueuingService>(); | ||
}; | ||
} | ||
} | ||
|
||
public Action<WebApplication> ConfigureMiddleware | ||
{ | ||
get { return _ => { }; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,13 +18,29 @@ | |
"LocalMachineJsonFileStore": { | ||
"RootPath": "./saastack/local" | ||
} | ||
}, | ||
"Notifications": { | ||
"SenderProductName": "SaaStack", | ||
"SenderEmailAddress": "[email protected]", | ||
"SenderDisplayName": "Support" | ||
} | ||
}, | ||
"Hosts": { | ||
"AncillaryApi": { | ||
"BaseUrl": "https://localhost:5001", | ||
"HmacAuthNSecret": "asecret" | ||
}, | ||
"IdentityApi": { | ||
"BaseUrl": "https://localhost:5001", | ||
"PasswordCredential": { | ||
"CooldownPeriodInMinutes": 5, | ||
"MaxFailedLogins": 5 | ||
}, | ||
"JWT": { | ||
"SigningSecret": "asecretsigningkey", | ||
"DefaultExpiryInMinutes": 15 | ||
} | ||
}, | ||
"WebsiteHost": { | ||
"BaseUrl": "https://localhost:5101" | ||
} | ||
|
Oops, something went wrong.