Skip to content

Commit 8521f46

Browse files
committed
Add Contracts & Reference Projects For Users & Credentials
1 parent 8a9221a commit 8521f46

File tree

113 files changed

+1340
-352
lines changed

Some content is hidden

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

113 files changed

+1340
-352
lines changed

UltimateAuth.slnx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@
1515
<Project Path="src/CodeBeam.UltimateAuth.Client/CodeBeam.UltimateAuth.Client.csproj" Id="eb60a3b7-ba9d-48c9-98ad-b28e879b23bf" />
1616
<Project Path="src/CodeBeam.UltimateAuth.Core/CodeBeam.UltimateAuth.Core.csproj" />
1717
<Project Path="src/CodeBeam.UltimateAuth.Server/CodeBeam.UltimateAuth.Server.csproj" Id="0a8cdd12-a8c4-4530-87e8-ae778c46322b" />
18-
<Project Path="src/users/CodeBeam.UltimateAuth.Users/CodeBeam.UltimateAuth.Users.csproj" Id="30d5db36-6dc8-46f6-9139-8b6b3d6053d5" />
18+
<Project Path="src/credentials/CodeBeam.UltimateAuth.Credentials.Contracts/CodeBeam.UltimateAuth.Credentials.Contracts.csproj" Id="88b70848-fa74-40ea-bf34-3fa2f70f4f37" />
1919
<Project Path="src/credentials/CodeBeam.UltimateAuth.Credentials.EntityFrameworkCore/CodeBeam.UltimateAuth.Credentials.EntityFrameworkCore.csproj" Id="1fd362d5-864b-4bb3-97be-9095d94cfdba" />
2020
<Project Path="src/credentials/CodeBeam.UltimateAuth.Credentials.InMemory/CodeBeam.UltimateAuth.Credentials.InMemory.csproj" Id="62ee7b1d-46ce-4f2e-985d-1e794f891b8b" />
21+
<Project Path="src/credentials/CodeBeam.UltimateAuth.Credentials.Reference/CodeBeam.UltimateAuth.Credentials.Reference.csproj" Id="ca03a140-f3dc-4a21-9b7d-895a3b10808b" />
2122
<Project Path="src/credentials/CodeBeam.UltimateAuth.Credentials/CodeBeam.UltimateAuth.Credentials.csproj" Id="2281c3b5-1d60-4542-a673-553f96eed25b" />
2223
<Project Path="src/security/CodeBeam.UltimateAuth.Security.Argon2/CodeBeam.UltimateAuth.Security.Argon2.csproj" Id="6abfb7a6-ea36-42db-a843-38054dd40fd8" />
2324
<Project Path="src/sessions/CodeBeam.UltimateAuth.Sessions.EntityFrameworkCore/CodeBeam.UltimateAuth.Sessions.EntityFrameworkCore.csproj" Id="5b9a090d-1689-4a81-9dfa-3ba69f0bda38" />
2425
<Project Path="src/sessions/CodeBeam.UltimateAuth.Sessions.InMemory/CodeBeam.UltimateAuth.Sessions.InMemory.csproj" Id="fc9bfef0-8a89-4639-81ee-3f84f6e33816" />
2526
<Project Path="src/tokens/CodeBeam.UltimateAuth.Tokens.EntityFrameworkCore/CodeBeam.UltimateAuth.Tokens.EntityFrameworkCore.csproj" Id="6eb14b32-0b56-460f-a2b2-f95d28bad625" />
2627
<Project Path="src/tokens/CodeBeam.UltimateAuth.Tokens.InMemory/CodeBeam.UltimateAuth.Tokens.InMemory.csproj" Id="8220884e-4958-4b49-8c69-56ce9d2b6c6f" />
28+
<Project Path="src/users/CodeBeam.UltimateAuth.Users.Contracts/CodeBeam.UltimateAuth.Users.Contracts.csproj" Id="3a04f065-8f9d-46b3-9726-1febffe6d46f" />
2729
<Project Path="src/users/CodeBeam.UltimateAuth.Users.InMemory/CodeBeam.UltimateAuth.Users.InMemory.csproj" Id="7ce3df22-4773-4b9b-afd0-8ba506e0f9de" />
30+
<Project Path="src/users/CodeBeam.UltimateAuth.Users.Reference/CodeBeam.UltimateAuth.Users.Reference.csproj" Id="601176dd-b760-4b6f-9cc7-c618134ae178" />
31+
<Project Path="src/users/CodeBeam.UltimateAuth.Users/CodeBeam.UltimateAuth.Users.csproj" Id="30d5db36-6dc8-46f6-9139-8b6b3d6053d5" />
2832
</Solution>

src/CodeBeam.UltimateAuth.Client/CodeBeam.UltimateAuth.Client.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030

3131
<ItemGroup>
3232
<ProjectReference Include="..\CodeBeam.UltimateAuth.Core\CodeBeam.UltimateAuth.Core.csproj" />
33+
<ProjectReference Include="..\credentials\CodeBeam.UltimateAuth.Credentials.Contracts\CodeBeam.UltimateAuth.Credentials.Contracts.csproj" />
34+
<ProjectReference Include="..\users\CodeBeam.UltimateAuth.Users.Contracts\CodeBeam.UltimateAuth.Users.Contracts.csproj" />
3335
</ItemGroup>
3436

3537
</Project>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using CodeBeam.UltimateAuth.Core.Contracts;
2+
3+
namespace CodeBeam.UltimateAuth.Core.Abstractions;
4+
5+
public interface IAuthContextFactory
6+
{
7+
AuthContext Create(DateTimeOffset? at = null);
8+
}
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 IAccessAuthority
6+
{
7+
AccessDecision Decide(AccessContext context);
8+
}
9+
}
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 IAccessInvariant
6+
{
7+
AccessDecision Decide(AccessContext 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 IAccessPolicy
6+
{
7+
bool AppliesTo(AccessContext context);
8+
AccessDecision Decide(AccessContext context);
9+
}
10+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using CodeBeam.UltimateAuth.Core.Contracts;
2+
using CodeBeam.UltimateAuth.Core.Domain;
3+
4+
namespace CodeBeam.UltimateAuth.Core.Abstractions
5+
{
6+
public interface ISessionService
7+
{
8+
Task RevokeAllAsync(AuthContext authContext, UserKey userKey, CancellationToken ct = default);
9+
Task RevokeAllExceptChainAsync(AuthContext authContext, UserKey userKey, SessionChainId exceptChainId, CancellationToken ct = default);
10+
Task RevokeRootAsync(AuthContext authContext, UserKey userKey, CancellationToken ct = default);
11+
}
12+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using CodeBeam.UltimateAuth.Core.Domain;
2+
3+
namespace CodeBeam.UltimateAuth.Core.Contracts
4+
{
5+
public sealed class AccessContext
6+
{
7+
public UserKey UserKey { get; init; }
8+
public string Action { get; init; } = default!;
9+
public string? Resource { get; init; }
10+
public string? ResourceId { get; init; }
11+
public IReadOnlyDictionary<string, object>? Attributes { get; init; }
12+
}
13+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
namespace CodeBeam.UltimateAuth.Core.Contracts
2+
{
3+
public sealed record AccessDecision
4+
{
5+
public bool IsAllowed { get; }
6+
public bool RequiresReauthentication { get; }
7+
public string? DenyReason { get; }
8+
9+
private AccessDecision(
10+
bool isAllowed,
11+
bool requiresReauthentication,
12+
string? denyReason)
13+
{
14+
IsAllowed = isAllowed;
15+
RequiresReauthentication = requiresReauthentication;
16+
DenyReason = denyReason;
17+
}
18+
19+
public static AccessDecision Allow()
20+
=> new(
21+
isAllowed: true,
22+
requiresReauthentication: false,
23+
denyReason: null);
24+
25+
public static AccessDecision Deny(string reason)
26+
=> new(
27+
isAllowed: false,
28+
requiresReauthentication: false,
29+
denyReason: reason);
30+
31+
public static AccessDecision ReauthenticationRequired(string? reason = null)
32+
=> new(
33+
isAllowed: false,
34+
requiresReauthentication: true,
35+
denyReason: reason);
36+
37+
public bool IsDenied =>
38+
!IsAllowed && !RequiresReauthentication;
39+
}
40+
}

src/CodeBeam.UltimateAuth.Core/Contracts/Authority/AuthenticationContext.cs

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)