Files
admin/_docs/02_document/modules/services_auth_service.md
T
Oleksandr Bezdieniezhnykh 3a925b9b0f
ci/woodpecker/push/01-test Pipeline failed
ci/woodpecker/push/02-build-push unknown status
refactor: remove obsolete resource download and installer endpoints
- Deleted the `POST /resources/get/{dataFolder?}` and `GET /resources/get-installer` endpoints as part of the architectural shift towards simplified resource management.
- Removed associated methods and configurations, including `ResourcesService.GetEncryptedResource`, `ResourcesService.GetInstaller`, and related properties in `ResourcesConfig`.
- Cleaned up environment variables and configuration files to reflect the removal of installer-related settings.
- Eliminated the `GetResourceRequest` DTO and its validator, along with the `WrongResourceName` error code.
- Updated documentation to clarify the changes in resource handling and the retirement of per-user file encryption.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-14 04:17:55 +03:00

1.9 KiB

Module: Azaion.Services.AuthService

Purpose

JWT token creation and current-user resolution from HTTP context claims.

Public Interface

IAuthService

Method Signature Description
GetCurrentUser Task<User?> GetCurrentUser() Extracts email from JWT claims, returns full User entity
CreateToken string CreateToken(User user) Generates a signed JWT token for the given user

Internal Logic

  • GetCurrentUser: reads ClaimTypes.Name from HttpContext.User.Claims, then delegates to IUserService.GetByEmail.
  • CreateToken: builds a SecurityTokenDescriptor with claims (NameIdentifier = user ID, Name = email, Role = role), signs with HMAC-SHA256 using the configured secret, sets expiry from JwtConfig.TokenLifetimeHours.

Private method:

  • GetCurrentUserEmail — extracts email from claims dictionary.

Dependencies

  • IHttpContextAccessor — for accessing current HTTP context
  • IOptions<JwtConfig> — JWT configuration
  • IUserService — for GetByEmail lookup
  • System.IdentityModel.Tokens.Jwt
  • Microsoft.IdentityModel.Tokens

Consumers

  • Program.cs /login endpoint — calls CreateToken after successful validation
  • Program.cs /users/current — calls GetCurrentUser (the previously listed /resources/get, /resources/get-installer, /resources/check consumers were removed in cycle 2 / by AZ-197 along with their endpoints)

Data Models

None.

Configuration

Uses JwtConfig (Issuer, Audience, Secret, TokenLifetimeHours).

External Integrations

None.

Security

  • Token includes user ID, email, and role as claims
  • Signed with HMAC-SHA256
  • Expiry controlled by TokenLifetimeHours config
  • Token validation parameters are configured in Program.cs (ValidateIssuer, ValidateAudience, ValidateLifetime, ValidateIssuerSigningKey)

Tests

None.