mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-10-14 17:54:42 +00:00
Move Infrastructure.Jwt into Features.Users (#287)
This commit is contained in:
@@ -89,7 +89,6 @@ flowchart TB
|
||||
subgraph INFRA["Infrastructure Layer"]
|
||||
direction LR
|
||||
I1["Database.Connection"]
|
||||
I2["Infrastructure.Jwt"]
|
||||
I3["Infrastructure.PasswordHashing"]
|
||||
I4["Infrastructure.Email /<br/>Email.Templates"]
|
||||
I5["Infrastructure.FileUpload"]
|
||||
@@ -133,7 +132,6 @@ own
|
||||
|
||||
- Every `Features.*` project (for controller/MediatR discovery)
|
||||
- `Shared.Contracts`, `Shared.Application`
|
||||
- `Infrastructure.Jwt` (for the auth middleware)
|
||||
|
||||
**Rules**:
|
||||
|
||||
@@ -167,10 +165,9 @@ brewery photo upload command) rather than bound to an HTTP route directly.
|
||||
|
||||
- `Domain.Entities`, `Domain.Exceptions`
|
||||
- `Database.Connection` (generic ADO.NET connection/command plumbing) plus
|
||||
whichever infrastructure project the slice needs (`Infrastructure.Jwt`/
|
||||
`Infrastructure.PasswordHashing` for Users, `Infrastructure.Email`/
|
||||
`Infrastructure.Email.Templates` for Emails, `Infrastructure.FileUpload` for
|
||||
PhotoUpload)
|
||||
whichever infrastructure project the slice needs (`Infrastructure.PasswordHashing`
|
||||
for Users, `Infrastructure.Email`/`Infrastructure.Email.Templates` for
|
||||
Emails, `Infrastructure.FileUpload` for PhotoUpload)
|
||||
- `Shared.Contracts`, `Shared.Application`
|
||||
- No other `Features.*` project, with two exceptions: `Features.Users`
|
||||
references `Features.PhotoUpload` directly for avatar uploads, and
|
||||
@@ -210,7 +207,6 @@ whichever slices need them
|
||||
| Project | Description |
|
||||
| -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `Database.Connection` | Generic ADO.NET connection/command plumbing (`DefaultSqlConnectionFactory`, the abstract `DapperRepository` base class), not domain-specific; each slice's own `Repository/` folder builds on this. |
|
||||
| `Infrastructure.Jwt` | JWT token generation and validation. |
|
||||
| `Infrastructure.PasswordHashing` | Argon2id password hashing. |
|
||||
| `Infrastructure.Email` | Email sending capabilities (SMTP/MailKit). |
|
||||
| `Infrastructure.Email.Templates` | Email template rendering (Razor components). |
|
||||
|
||||
@@ -97,7 +97,7 @@ see the notes for what else each of those foundation projects pulls in.
|
||||
|
||||
- **Omitted from the diagram**:
|
||||
- `Domain.Exceptions` (referenced by nearly every project directly, including
|
||||
all of `Shared.Contracts`, `Infrastructure.Jwt`, and each feature slice)
|
||||
all of `Shared.Contracts` and each feature slice)
|
||||
- `Infrastructure.Configuration` (the shared options-binding project
|
||||
referenced by `Database.Connection`, `Infrastructure.Email`,
|
||||
`Infrastructure.FileUpload`, and `Features.Emails` directly)
|
||||
|
||||
@@ -23,7 +23,6 @@ end
|
||||
|
||||
subgraph INFRA["Slice-specific Infrastructure"]
|
||||
direction LR
|
||||
JWT["Infrastructure.Jwt"]
|
||||
PwdHash["Infrastructure.PasswordHashing"]
|
||||
FileUpload["Infrastructure.FileUpload"]
|
||||
Email["Infrastructure.Email"]
|
||||
@@ -36,6 +35,6 @@ BrewerySlice --> FOUNDATION
|
||||
LocationsSlice --> FOUNDATION
|
||||
BeersSlice --> FOUNDATION
|
||||
PhotoSlice --> FOUNDATION & FileUpload
|
||||
UsersSlice --> FOUNDATION & JWT & PwdHash
|
||||
UsersSlice --> FOUNDATION & PwdHash
|
||||
EmailsSlice --> Email & EmailTemplates
|
||||
DBConn -- Dapper SQL, no ORM --> Tables[("SQL Server<br>Tables")]
|
||||
|
||||
@@ -22,7 +22,7 @@ The Biergarten API validates JSON Web Tokens (JWTs) across three token types:
|
||||
|
||||
### Infrastructure layer
|
||||
|
||||
#### [ITokenInfrastructure](../../web/backend/Infrastructure/Infrastructure.Jwt/ITokenInfrastructure.cs)
|
||||
#### [ITokenInfrastructure](../../web/backend/Features/Features.Users/Services/ITokenInfrastructure.cs)
|
||||
|
||||
Low-level JWT operations.
|
||||
|
||||
@@ -32,7 +32,7 @@ Low-level JWT operations.
|
||||
- `ValidateJwtAsync()` - Validates token signature, expiration, and format
|
||||
|
||||
**Implementation:**
|
||||
[JwtInfrastructure.cs](../../web/backend/Infrastructure/Infrastructure.Jwt/JwtInfrastructure.cs)
|
||||
[JwtInfrastructure.cs](../../web/backend/Features/Features.Users/Services/JwtInfrastructure.cs)
|
||||
|
||||
- Uses Microsoft.IdentityModel.JsonWebTokens.JsonWebTokenHandler
|
||||
- Algorithm: HS256 (HMAC-SHA256)
|
||||
@@ -76,12 +76,11 @@ directly, bypassing the `Features.Users` slice entirely.
|
||||
- Extracts and validates claims (Sub, UniqueName)
|
||||
- Throws `UnauthorizedException` on validation failure
|
||||
|
||||
`TokenService` is registered by `Features.Users`' own `AddFeaturesUsers()`
|
||||
extension method, except for the lower-level `ITokenInfrastructure` (JWT
|
||||
signing/verification) it depends on, which is registered by the host
|
||||
(`API.Core/ServiceCollectionExtensions.cs`, via `AddCoreInfrastructure()`,
|
||||
called from `Program.cs`) since `JwtAuthenticationHandler` (host-level auth
|
||||
middleware) also depends on it directly.
|
||||
`TokenService` and the lower-level `ITokenInfrastructure` (JWT
|
||||
signing/verification) it depends on are both registered by `Features.Users`'
|
||||
own `AddFeaturesUsers()` extension method. `JwtAuthenticationHandler`
|
||||
(host-level auth middleware) also depends on `ITokenInfrastructure` directly,
|
||||
resolving it from the same DI container.
|
||||
|
||||
### Integration points
|
||||
|
||||
|
||||
Reference in New Issue
Block a user