Skip to content

Commit

Permalink
Unify id generation method names
Browse files Browse the repository at this point in the history
  • Loading branch information
kirill-abblix committed Apr 13, 2024
1 parent 022629d commit f466640
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Abblix.Oidc.Server.Mvc/AuthenticationSchemeAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public async IAsyncEnumerable<AuthSession> GetAvailableAuthSessions()
if (string.IsNullOrEmpty(sessionId))
{
throw new InvalidOperationException(
$"Use {nameof(SessionIdGenerator)}.{nameof(SessionIdGenerator.NewId)}() to generate a new session Id when calling .SignInAsync() method");
$"Use {nameof(SessionIdGenerator)}.{nameof(SessionIdGenerator.GenerateSessionId)}() to generate a new session Id when calling .SignInAsync() method");
}

var authenticationTime = properties.GetString(JwtClaimTypes.AuthenticationTime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ public interface ISessionIdGenerator
/// <returns>A new, unique session identifier as a string. The format and characteristics of the session ID
/// (e.g., length, characters used) should be designed to enhance security and minimize the risk of session
/// hijacking or collision.</returns>
string NewId();
string GenerateSessionId();
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ public interface ITokenIdGenerator
/// and characteristics of the generated ID, such as its length, randomness, and URL-safety.
/// </summary>
/// <returns>A unique identifier suitable for use as a JWT ID.</returns>
string NewId();
string GenerateTokenId();
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ public class SessionIdGenerator : ISessionIdGenerator
/// </summary>
/// <returns>A string representing a URL-safe, cryptographically strong random session identifier. The identifier
/// is encoded in a way that makes it suitable for use in HTTP URLs, cookies, or any other URL-based contexts.</returns>
public string NewId() => HttpServerUtility.UrlTokenEncode(CryptoRandom.GetRandomBytes(32));
public string GenerateSessionId() => HttpServerUtility.UrlTokenEncode(CryptoRandom.GetRandomBytes(32));
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ public class TokenIdGenerator : ITokenIdGenerator
/// HTTP URL-safe Base64 encoding, resulting in a string suitable for use as a JWT ID.
/// </summary>
/// <returns>A URL-safe, randomly generated unique identifier for a JWT.</returns>
public string NewId() => HttpServerUtility.UrlTokenEncode(CryptoRandom.GetRandomBytes(32));
public string GenerateTokenId() => HttpServerUtility.UrlTokenEncode(CryptoRandom.GetRandomBytes(32));
}
2 changes: 1 addition & 1 deletion Abblix.Oidc.Server/Features/Tokens/AccessTokenService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public async Task<EncodedJsonWebToken> CreateAccessTokenAsync(
},
Payload =
{
JwtId = _tokenIdGenerator.NewId(),
JwtId = _tokenIdGenerator.GenerateTokenId(),
IssuedAt = issuedAt,
NotBefore = issuedAt,
ExpiresAt = issuedAt + clientInfo.AccessTokenExpiresIn,
Expand Down
2 changes: 1 addition & 1 deletion Abblix.Oidc.Server/Features/Tokens/RefreshTokenService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public RefreshTokenService(
},
Payload =
{
JwtId = _tokenIdGenerator.NewId(),
JwtId = _tokenIdGenerator.GenerateTokenId(),
IssuedAt = issuedAt,
NotBefore = now,
ExpiresAt = expiresAt,
Expand Down

0 comments on commit f466640

Please sign in to comment.