Skip to content

Commit cdcb780

Browse files
authored
Finalize Server Project With Minimum Features (Part 3) (#5)
* Start to Authority Layer * Complete Basic Authority Layer * Finalize Server Project's Layers * Change Slnx
1 parent e0b0d01 commit cdcb780

File tree

92 files changed

+1595
-620
lines changed

Some content is hidden

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

92 files changed

+1595
-620
lines changed

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.Server.Users.csproj" Id="30d5db36-6dc8-46f6-9139-8b6b3d6053d5" />
6+
<Project Path="src/CodeBeam.UltimateAuth.Users/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" />
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using CodeBeam.UltimateAuth.Core.Contracts;
2+
3+
namespace CodeBeam.UltimateAuth.Core.Abstractions
4+
{
5+
public interface IAuthAuthority
6+
{
7+
AuthorizationResult Decide(AuthContext context);
8+
}
9+
10+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using CodeBeam.UltimateAuth.Core.Contracts;
2+
3+
namespace CodeBeam.UltimateAuth.Core.Abstractions
4+
{
5+
public interface IAuthorityInvariant
6+
{
7+
AuthorizationResult Decide(AuthContext context);
8+
}
9+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using CodeBeam.UltimateAuth.Core.Contracts;
2+
3+
namespace CodeBeam.UltimateAuth.Core.Abstractions
4+
{
5+
public interface IAuthorityPolicy
6+
{
7+
bool AppliesTo(AuthContext context);
8+
AuthorizationResult Decide(AuthContext context);
9+
}
10+
}

src/CodeBeam.UltimateAuth.Core/Abstractions/Infrastructure/IClock.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
/// </summary>
77
public interface IClock
88
{
9-
DateTime UtcNow { get; }
9+
DateTimeOffset UtcNow { get; }
1010
}
1111
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using CodeBeam.UltimateAuth.Core.Contracts;
2+
3+
namespace CodeBeam.UltimateAuth.Core.Abstractions
4+
{
5+
public interface IRefreshTokenResolver<TUserId>
6+
{
7+
Task<ResolvedRefreshSession<TUserId>?> ResolveAsync(string? tenantId, string refreshToken, DateTimeOffset now, CancellationToken ct = default);
8+
}
9+
10+
}

src/CodeBeam.UltimateAuth.Core/Abstractions/Issuers/ISessionIssuer.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,18 @@
33

44
namespace CodeBeam.UltimateAuth.Core.Abstractions
55
{
6-
/// <summary>
7-
/// Issues and manages authentication sessions.
8-
/// </summary>
96
public interface ISessionIssuer<TUserId>
107
{
11-
Task<IssuedSession<TUserId>> IssueAsync(AuthenticatedSessionContext<TUserId> context, ISessionChain<TUserId> chain, CancellationToken cancellationToken = default);
8+
Task<IssuedSession<TUserId>> IssueLoginSessionAsync(AuthenticatedSessionContext<TUserId> context, CancellationToken cancellationToken = default);
9+
10+
Task<IssuedSession<TUserId>> RotateSessionAsync(SessionRotationContext<TUserId> context, CancellationToken cancellationToken = default);
11+
12+
Task RevokeSessionAsync(string? tenantId, AuthSessionId sessionId, DateTimeOffset at, CancellationToken cancellationToken = default);
13+
14+
Task RevokeChainAsync(string? tenantId, ChainId chainId, DateTimeOffset at, CancellationToken cancellationToken = default);
15+
16+
Task RevokeAllChainsAsync(string? tenantId, TUserId userId, ChainId? exceptChainId, DateTimeOffset at, CancellationToken ct = default);
17+
18+
Task RevokeRootAsync(string? tenantId, TUserId userId, DateTimeOffset at,CancellationToken ct = default);
1219
}
1320
}

src/CodeBeam.UltimateAuth.Core/Abstractions/Services/IUAuthSessionService.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@ namespace CodeBeam.UltimateAuth.Core.Abstractions
99
/// <typeparam name="TUserId">The type used to uniquely identify the user.</typeparam>
1010
public interface IUAuthSessionService<TUserId>
1111
{
12-
Task<SessionValidationResult<TUserId>> ValidateSessionAsync(string? tenantId, AuthSessionId sessionId, DateTime at);
12+
Task<SessionValidationResult<TUserId>> ValidateSessionAsync(string? tenantId, AuthSessionId sessionId, DateTimeOffset at);
1313

1414
Task<IReadOnlyList<ISessionChain<TUserId>>> GetChainsAsync(string? tenantId, TUserId userId);
1515

1616
Task<IReadOnlyList<ISession<TUserId>>> GetSessionsAsync(string? tenantId, ChainId chainId);
1717

1818
Task<ISession<TUserId>?> GetCurrentSessionAsync(string? tenantId, AuthSessionId sessionId);
1919

20-
Task RevokeSessionAsync(string? tenantId, AuthSessionId sessionId, DateTime at);
20+
Task RevokeSessionAsync(string? tenantId, AuthSessionId sessionId, DateTimeOffset at);
2121

22-
Task RevokeChainAsync(string? tenantId, ChainId chainId, DateTime at);
22+
Task RevokeChainAsync(string? tenantId, ChainId chainId, DateTimeOffset at);
2323

2424
Task<ChainId?> ResolveChainIdAsync(string? tenantId, AuthSessionId sessionId);
2525

26-
Task RevokeAllChainsAsync(string? tenantId, TUserId userId, ChainId? exceptChainId, DateTime at);
26+
Task RevokeAllChainsAsync(string? tenantId, TUserId userId, ChainId? exceptChainId, DateTimeOffset at);
2727

2828
// Hard revoke - admin
29-
Task RevokeRootAsync(string? tenantId, TUserId userId, DateTime at);
29+
Task RevokeRootAsync(string? tenantId, TUserId userId, DateTimeOffset at);
3030

3131
Task<IssuedSession<TUserId>> IssueSessionAfterAuthenticationAsync(string? tenantId, AuthenticatedSessionContext<TUserId> context, CancellationToken cancellationToken = default);
3232
}

src/CodeBeam.UltimateAuth.Core/Abstractions/Stores/ISessionStore.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,22 @@ Task RotateSessionAsync(
3737
Task RevokeSessionAsync(
3838
string? tenantId,
3939
AuthSessionId sessionId,
40-
DateTime at);
40+
DateTimeOffset at);
4141

4242
/// <summary>
4343
/// Revokes all sessions for a specific user (all devices).
4444
/// </summary>
4545
Task RevokeAllSessionsAsync(
4646
string? tenantId,
4747
TUserId userId,
48-
DateTime at);
48+
DateTimeOffset at);
4949

5050
/// <summary>
5151
/// Revokes all sessions within a specific chain (single device).
5252
/// </summary>
5353
Task RevokeChainAsync(
5454
string? tenantId,
5555
ChainId chainId,
56-
DateTime at);
56+
DateTimeOffset at);
5757
}
5858
}

src/CodeBeam.UltimateAuth.Core/Abstractions/Stores/ISessionStoreKernel.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ namespace CodeBeam.UltimateAuth.Core.Abstractions
88
/// </summary>
99
public interface ISessionStoreKernel<TUserId>
1010
{
11+
/// <summary>
12+
/// Executes multiple store operations as a single atomic unit.
13+
/// Implementations must ensure transactional consistency where supported.
14+
/// </summary>
15+
Task ExecuteAsync(Func<Task> action);
16+
1117
/// <summary>
1218
/// Retrieves a session by its identifier within the given tenant context.
1319
/// </summary>
@@ -31,7 +37,7 @@ public interface ISessionStoreKernel<TUserId>
3137
/// <param name="tenantId">The tenant identifier, or <c>null</c>.</param>
3238
/// <param name="sessionId">The session identifier.</param>
3339
/// <param name="at">The UTC timestamp of revocation.</param>
34-
Task RevokeSessionAsync(string? tenantId, AuthSessionId sessionId, DateTime at);
40+
Task RevokeSessionAsync(string? tenantId, AuthSessionId sessionId, DateTimeOffset at);
3541

3642
/// <summary>
3743
/// Returns all sessions belonging to the specified chain, ordered according to store implementation rules.
@@ -62,7 +68,7 @@ public interface ISessionStoreKernel<TUserId>
6268
/// <param name="tenantId">The tenant identifier, or <c>null</c>.</param>
6369
/// <param name="chainId">The chain to revoke.</param>
6470
/// <param name="at">The UTC timestamp of revocation.</param>
65-
Task RevokeChainAsync(string? tenantId, ChainId chainId, DateTime at);
71+
Task RevokeChainAsync(string? tenantId, ChainId chainId, DateTimeOffset at);
6672

6773
/// <summary>
6874
/// Retrieves the active session identifier for the specified chain.
@@ -112,14 +118,14 @@ public interface ISessionStoreKernel<TUserId>
112118
/// <param name="tenantId">The tenant identifier, or <c>null</c>.</param>
113119
/// <param name="userId">The user whose root should be revoked.</param>
114120
/// <param name="at">The UTC timestamp of revocation.</param>
115-
Task RevokeSessionRootAsync(string? tenantId, TUserId userId, DateTime at);
121+
Task RevokeSessionRootAsync(string? tenantId, TUserId userId, DateTimeOffset at);
116122

117123
/// <summary>
118124
/// Removes expired sessions from the store while leaving chains and session roots intact. Cleanup strategy is determined by the store implementation.
119125
/// </summary>
120126
/// <param name="tenantId">The tenant identifier, or <c>null</c>.</param>
121127
/// <param name="now">The current UTC timestamp.</param>
122-
Task DeleteExpiredSessionsAsync(string? tenantId, DateTime now);
128+
Task DeleteExpiredSessionsAsync(string? tenantId, DateTimeOffset at);
123129

124130
/// <summary>
125131
/// Retrieves the chain identifier associated with the specified session.
@@ -128,11 +134,5 @@ public interface ISessionStoreKernel<TUserId>
128134
/// <param name="sessionId">The session identifier.</param>
129135
/// <returns>The chain identifier or <c>null</c>.</returns>
130136
Task<ChainId?> GetChainIdBySessionAsync(string? tenantId, AuthSessionId sessionId);
131-
132-
/// <summary>
133-
/// Executes multiple store operations as a single atomic unit.
134-
/// Implementations must ensure transactional consistency where supported.
135-
/// </summary>
136-
Task ExecuteAsync(Func<Task> action);
137137
}
138138
}

0 commit comments

Comments
 (0)