Skip to content

Commit 0bfc56a

Browse files
author
Vadim Belov
committed
Add XML docs and widen access for token methods
Added detailed XML documentation to CreateAccessToken and AddRefreshTokenToCookie in BaseAuthController. Changed their access modifiers from private protected to internal protected for broader accessibility within the assembly. No functional changes were made.
1 parent 30d3f71 commit 0bfc56a

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

Sources/EasyExtensions.AspNetCore.Authorization/Controllers/BaseAuthController.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,18 @@ public virtual IEnumerable<KeyValuePair<string, string>> GetAdditionalTokenClaim
372372
return [];
373373
}
374374

375-
private protected string CreateAccessToken(Guid userId, IEnumerable<string> roles)
375+
/// <summary>
376+
/// Generates a JWT access token for the specified user, including their roles and any additional claims.
377+
/// </summary>
378+
/// <remarks>The generated token includes standard claims such as the subject identifier, as well
379+
/// as any additional claims retrieved for the user. Roles are added as claims to support role-based
380+
/// authorization scenarios.</remarks>
381+
/// <param name="userId">The unique identifier of the user for whom the access token is being generated.</param>
382+
/// <param name="roles">A collection of role names to be included as claims in the access token. Each role represents a permission
383+
/// or group associated with the user.</param>
384+
/// <returns>A string containing the generated JWT access token that can be used to authenticate the user in subsequent
385+
/// requests.</returns>
386+
internal protected string CreateAccessToken(Guid userId, IEnumerable<string> roles)
376387
{
377388
return _tokenProvider.CreateToken(cb =>
378389
{
@@ -389,7 +400,15 @@ private protected string CreateAccessToken(Guid userId, IEnumerable<string> role
389400
});
390401
}
391402

392-
private protected void AddRefreshTokenToCookie(string refreshToken)
403+
/// <summary>
404+
/// Adds the specified refresh token to the HTTP response cookies to support secure session renewal.
405+
/// </summary>
406+
/// <remarks>The refresh token cookie is configured with security best practices: it is marked as
407+
/// secure, HTTP-only, and uses a strict SameSite policy to help prevent cross-site request forgery (CSRF)
408+
/// attacks. The cookie's expiration is determined by the application's configured refresh token
409+
/// lifetime.</remarks>
410+
/// <param name="refreshToken">The refresh token to be stored in the response cookie. Cannot be null or empty.</param>
411+
internal protected void AddRefreshTokenToCookie(string refreshToken)
393412
{
394413
Response.Cookies.Append(CookieRefreshTokenName, refreshToken, new()
395414
{

0 commit comments

Comments
 (0)