=== Summary: 675 files | 7 generated | 484 fresh | 4605 untracked | 4268 adopted | 355 marked | 466 validated-ok | 2+0 stale (sig+body) | 0 skipped | 0 failed | elapsed 11:08:11.442 (40091.44s) ===

This commit is contained in:
julian
2026-06-28 02:50:05 -07:00
parent a19fb90902
commit 586f02a2ca
654 changed files with 5260 additions and 0 deletions
+4
View File
@@ -12,6 +12,7 @@ namespace adas_core.Domain.Utils;
/// <remarks>
/// This class is intended to be inherited by concrete implementations that define specific JWT processing behaviors.
/// </remarks>
/// <!-- aidoc:v1 sig=1fa4049 -->
public abstract class JwtHelper
{
/// <summary>
@@ -25,6 +26,7 @@ public abstract class JwtHelper
/// <param name="expiration">The token lifetime in minutes, added to the current UTC time to compute the expiration date.</param>
/// <param name="additionalClaims">Optional extra claims to merge into the token alongside the standard claims. If null, only the default claims are included.</param>
/// <returns>A <see cref="JwtSecurityToken"/> signed with HMAC-SHA256 and configured with the supplied issuer, audience, expiration, and claims.</returns>
/// <!-- aidoc:v1 sig=7df0b13 body=543eca7 -->
public static JwtSecurityToken GetJwtToken(
string username,
string secret,
@@ -70,6 +72,7 @@ public abstract class JwtHelper
/// Generates a cryptographically secure refresh token by producing 64 random bytes using <see cref="RandomNumberGenerator"/> and returning the value as a Base64-encoded string.
/// </summary>
/// <returns>A Base64-encoded string representation of a 64-byte cryptographically random sequence suitable for use as a refresh token.</returns>
/// <!-- aidoc:v1 sig=6a19dd4 body=ba66473 -->
public static string GenerateRefreshToken()
{
var randomNumber = new byte[64];
@@ -83,6 +86,7 @@ public abstract class JwtHelper
/// </summary>
/// <param name="principal"></param>
/// <returns></returns>
/// <!-- aidoc:v1 sig=df50964 body=4874c36 -->
public static string? GetUsernameFromPrincipal(ClaimsPrincipal principal)
{
var nameClaim = principal.Claims.FirstOrDefault(c => c.Type.Equals(ClaimTypes.NameIdentifier));