mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-10-15 10:04:44 +00:00
Fix fabricated ITokenService signatures and error-message claims in token-validation.md
This commit is contained in:
@@ -46,16 +46,23 @@ Token generation and validation live on the same slice-internal service.
|
|||||||
|
|
||||||
**Generation methods:**
|
**Generation methods:**
|
||||||
|
|
||||||
- `GenerateAccessToken(UserAccount)` - Creates 1-hour access token
|
- `GenerateAccessToken(Guid userId, string username)` - Creates 1-hour access
|
||||||
- `GenerateRefreshToken(UserAccount)` - Creates 21-day refresh token
|
|
||||||
- `GenerateConfirmationToken(UserAccount)` - Creates 30-minute confirmation
|
|
||||||
token
|
token
|
||||||
|
- `GenerateRefreshToken(Guid userId, string username)` - Creates 21-day
|
||||||
|
refresh token
|
||||||
|
- `GenerateConfirmationToken(Guid userId, string username)` - Creates
|
||||||
|
30-minute confirmation token
|
||||||
|
|
||||||
**Validation methods:**
|
**Validation methods:**
|
||||||
|
|
||||||
- `ValidateAccessTokenAsync(string token)` - Validates access tokens
|
|
||||||
- `ValidateRefreshTokenAsync(string token)` - Validates refresh tokens
|
- `ValidateRefreshTokenAsync(string token)` - Validates refresh tokens
|
||||||
- `ValidateConfirmationTokenAsync(string token)` - Validates confirmation tokens
|
- `ValidateConfirmationTokenAsync(string token)` - Validates confirmation
|
||||||
|
tokens
|
||||||
|
|
||||||
|
There is no `ValidateAccessTokenAsync` on `ITokenService`. Access-token
|
||||||
|
validation doesn't go through `ITokenService` at all: `JwtAuthenticationHandler`
|
||||||
|
(the host-level auth middleware) calls `ITokenInfrastructure.ValidateJwtAsync()`
|
||||||
|
directly, bypassing the `Features.Users` slice entirely.
|
||||||
|
|
||||||
**Returns (validation):** `ValidatedToken` record containing:
|
**Returns (validation):** `ValidatedToken` record containing:
|
||||||
|
|
||||||
@@ -172,12 +179,11 @@ Each token is validated for:
|
|||||||
|
|
||||||
### Error handling
|
### Error handling
|
||||||
|
|
||||||
Validation failures return HTTP 401 Unauthorized:
|
Validation failures return HTTP 401 Unauthorized. Regardless of the specific
|
||||||
|
cause (invalid signature, expired token, missing header, malformed claims),
|
||||||
- Invalid signature → "Invalid token"
|
`JwtAuthenticationHandler.HandleChallengeAsync` always returns the same
|
||||||
- Expired token → "Invalid token" (message doesn't reveal reason for security)
|
generic message: `"Unauthorized: Invalid or missing authentication token"` —
|
||||||
- Missing claims → "Invalid token"
|
it doesn't distinguish failure reasons in the response.
|
||||||
- Malformed claims → "Invalid token"
|
|
||||||
|
|
||||||
## Token lifecycle
|
## Token lifecycle
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user