Skip to content

Commit f093620

Browse files
committed
TokenService Implementation
1 parent 51f8fa0 commit f093620

70 files changed

Lines changed: 1325 additions & 108 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎UltimateAuth.slnx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<File Path="Readme.md" />
44
<File Path="Roadmap.md" />
55
</Folder>
6-
<Project Path="src/CodeBeam.UltimateAuth.AspNetCore/CodeBeam.UltimateAuth.AspNetCore.csproj" Id="30d5db36-6dc8-46f6-9139-8b6b3d6053d5" />
6+
<Project Path="src/CodeBeam.UltimateAuth.AspNetCore/CodeBeam.UltimateAuth.Server.Users.csproj" Id="30d5db36-6dc8-46f6-9139-8b6b3d6053d5" />
77
<Project Path="src/CodeBeam.UltimateAuth.Client/CodeBeam.UltimateAuth.Client.csproj" Id="eb60a3b7-ba9d-48c9-98ad-b28e879b23bf" />
88
<Project Path="src/CodeBeam.UltimateAuth.Core/CodeBeam.UltimateAuth.Core.csproj" />
99
<Project Path="src/CodeBeam.UltimateAuth.Server/CodeBeam.UltimateAuth.Server.csproj" Id="0a8cdd12-a8c4-4530-87e8-ae778c46322b" />

src/CodeBeam.UltimateAuth.AspNetCore/Handlers/.gitkeep renamed to src/CodeBeam.UltimateAuth.AspNetCore/Abstractions/.gitkeep

File renamed without changes.

src/CodeBeam.UltimateAuth.AspNetCore/CodeBeam.UltimateAuth.AspNetCore.csproj renamed to src/CodeBeam.UltimateAuth.AspNetCore/CodeBeam.UltimateAuth.Server.Users.csproj

File renamed without changes.

src/CodeBeam.UltimateAuth.Core/Abstractions/Issuers/ITokenHasher.cs renamed to src/CodeBeam.UltimateAuth.Core/Abstractions/ITokenHasher.cs

File renamed without changes.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using CodeBeam.UltimateAuth.Core.Models;
2+
3+
namespace CodeBeam.UltimateAuth.Core.Abstractions
4+
{
5+
/// <summary>
6+
/// Validates access tokens (JWT or opaque) and resolves
7+
/// the authenticated user context.
8+
/// </summary>
9+
public interface ITokenValidator
10+
{
11+
Task<TokenValidationResult<TUserId>> ValidateAsync<TUserId>(
12+
string token,
13+
TokenType type,
14+
CancellationToken ct = default);
15+
}
16+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace CodeBeam.UltimateAuth.Core.Abstractions
2+
{
3+
/// <summary>
4+
/// Securely hashes and verifies user passwords.
5+
/// Designed for slow, adaptive, memory-hard algorithms
6+
/// such as Argon2 or bcrypt.
7+
/// </summary>
8+
public interface IUAuthPasswordHasher
9+
{
10+
string Hash(string password);
11+
bool Verify(string password, string hash);
12+
}
13+
}

‎src/CodeBeam.UltimateAuth.Core/Abstractions/IUserIdConverter.cs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public interface IUserIdConverter<TUserId>
3131
/// Thrown when the input value cannot be parsed into a valid identifier.
3232
/// </exception>
3333
TUserId FromString(string value);
34+
bool TryFromString(string value, out TUserId userId);
3435

3536
/// <summary>
3637
/// Reconstructs a typed user identifier from its binary representation.
@@ -41,5 +42,6 @@ public interface IUserIdConverter<TUserId>
4142
/// Thrown when the input binary value cannot be parsed into a valid identifier.
4243
/// </exception>
4344
TUserId FromBytes(byte[] binary);
45+
bool TryFromBytes(byte[] binary, out TUserId userId);
4446
}
4547
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
namespace CodeBeam.UltimateAuth.Core.Abstractions
2+
{
3+
/// <summary>
4+
/// Responsible for creating new user identifiers.
5+
/// This abstraction allows UltimateAuth to remain
6+
/// independent from the concrete user ID type.
7+
/// </summary>
8+
/// <typeparam name="TUserId">User identifier type.</typeparam>
9+
public interface IUserIdFactory<TUserId>
10+
{
11+
/// <summary>
12+
/// Creates a new unique user identifier.
13+
/// </summary>
14+
TUserId Create();
15+
}
16+
}

‎src/CodeBeam.UltimateAuth.Core/Abstractions/Services/ISessionService.cs‎

Lines changed: 0 additions & 93 deletions
This file was deleted.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
using CodeBeam.UltimateAuth.Core.Models;
2+
3+
namespace CodeBeam.UltimateAuth.Core.Abstractions
4+
{
5+
/// <summary>
6+
/// Handles authentication flows such as login,
7+
/// logout, session refresh and reauthentication.
8+
/// </summary>
9+
public interface IUAuthFlowService
10+
{
11+
// ---------- LOGIN ----------
12+
Task<LoginResult> LoginAsync(
13+
LoginRequest request,
14+
CancellationToken ct = default);
15+
16+
Task<LoginResult> ExternalLoginAsync(
17+
ExternalLoginRequest request,
18+
CancellationToken ct = default);
19+
20+
// ---------- MFA ----------
21+
Task<MfaChallengeResult> BeginMfaAsync(
22+
BeginMfaRequest request,
23+
CancellationToken ct = default);
24+
25+
Task<LoginResult> CompleteMfaAsync(
26+
CompleteMfaRequest request,
27+
CancellationToken ct = default);
28+
29+
// ---------- SESSION FLOW ----------
30+
Task LogoutAsync(
31+
LogoutRequest request,
32+
CancellationToken ct = default);
33+
34+
Task LogoutAllAsync(
35+
LogoutAllRequest request,
36+
CancellationToken ct = default);
37+
38+
Task<SessionRefreshResult> RefreshSessionAsync(
39+
SessionRefreshRequest request,
40+
CancellationToken ct = default);
41+
42+
Task<ReauthResult> ReauthenticateAsync(
43+
ReauthRequest request,
44+
CancellationToken ct = default);
45+
46+
// ---------- PKCE ----------
47+
Task<PkceChallengeResult> CreatePkceChallengeAsync(
48+
PkceCreateRequest request,
49+
CancellationToken ct = default);
50+
51+
Task<PkceVerificationResult> VerifyPkceAsync(
52+
PkceVerifyRequest request,
53+
CancellationToken ct = default);
54+
55+
Task ConsumePkceAsync(
56+
PkceConsumeRequest request,
57+
CancellationToken ct = default);
58+
}
59+
}

0 commit comments

Comments
 (0)