Skip to content

Commit 342df09

Browse files
committed
Support Credential Level Lockout
1 parent d458639 commit 342df09

File tree

68 files changed

+676
-353
lines changed

Some content is hidden

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

68 files changed

+676
-353
lines changed

UltimateAuth.slnx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<Folder Name="/Tests/">
1313
<Project Path="tests/CodeBeam.UltimateAuth.Tests.Unit/CodeBeam.UltimateAuth.Tests.Unit.csproj" Id="6f4b22da-849a-4a79-b5c5-aee7cb1429a6" />
1414
</Folder>
15+
<Project Path="src/authentication/CodeBeam.UltimateAuth.Authentication.InMemory/CodeBeam.UltimateAuth.Authentication.InMemory.csproj" Id="bd87e254-0565-4fc5-950d-ee5bbb416079" />
1516
<Project Path="src/authorization/CodeBeam.UltimateAuth.Authorization.Contracts/CodeBeam.UltimateAuth.Authorization.Contracts.csproj" Id="40a23002-f885-42a8-bdd9-fd962ab28742" />
1617
<Project Path="src/authorization/CodeBeam.UltimateAuth.Authorization.InMemory/CodeBeam.UltimateAuth.Authorization.InMemory.csproj" Id="a1e6d007-bdc0-4574-b549-ec863757edd3" />
1718
<Project Path="src/authorization/CodeBeam.UltimateAuth.Authorization.Reference/CodeBeam.UltimateAuth.Authorization.Reference.csproj" Id="84b784d0-bb48-406a-a0d1-c600da667597" />

samples/UAuthHub/CodeBeam.UltimateAuth.Sample.UAuthHub/CodeBeam.UltimateAuth.Sample.UAuthHub.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
</ItemGroup>
1515

1616
<ItemGroup>
17+
<ProjectReference Include="..\..\..\src\authentication\CodeBeam.UltimateAuth.Authentication.InMemory\CodeBeam.UltimateAuth.Authentication.InMemory.csproj" />
1718
<ProjectReference Include="..\..\..\src\authorization\CodeBeam.UltimateAuth.Authorization.InMemory\CodeBeam.UltimateAuth.Authorization.InMemory.csproj" />
1819
<ProjectReference Include="..\..\..\src\authorization\CodeBeam.UltimateAuth.Authorization.Reference\CodeBeam.UltimateAuth.Authorization.Reference.csproj" />
1920
<ProjectReference Include="..\..\..\src\authorization\CodeBeam.UltimateAuth.Authorization\CodeBeam.UltimateAuth.Authorization.csproj" />

samples/UAuthHub/CodeBeam.UltimateAuth.Sample.UAuthHub/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using CodeBeam.UltimateAuth.Authentication.InMemory;
12
using CodeBeam.UltimateAuth.Authorization.InMemory;
23
using CodeBeam.UltimateAuth.Authorization.InMemory.Extensions;
34
using CodeBeam.UltimateAuth.Authorization.Reference.Extensions;
@@ -8,8 +9,6 @@
89
using CodeBeam.UltimateAuth.Credentials.Reference;
910
using CodeBeam.UltimateAuth.Sample.UAuthHub.Components;
1011
using CodeBeam.UltimateAuth.Security.Argon2;
11-
using CodeBeam.UltimateAuth.Server.Authentication;
12-
using CodeBeam.UltimateAuth.Server.Defaults;
1312
using CodeBeam.UltimateAuth.Server.Extensions;
1413
using CodeBeam.UltimateAuth.Sessions.InMemory;
1514
using CodeBeam.UltimateAuth.Tokens.InMemory;
@@ -57,6 +56,7 @@
5756
.AddUltimateAuthAuthorizationReference()
5857
.AddUltimateAuthInMemorySessions()
5958
.AddUltimateAuthInMemoryTokens()
59+
.AddUltimateAuthInMemoryAuthenticationSecurity()
6060
.AddUltimateAuthArgon2();
6161

6262
builder.Services.AddUltimateAuthClient(o =>

samples/blazor-server/CodeBeam.UltimateAuth.Sample.BlazorServer/CodeBeam.UltimateAuth.Sample.BlazorServer.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
</ItemGroup>
1616

1717
<ItemGroup>
18+
<ProjectReference Include="..\..\..\src\authentication\CodeBeam.UltimateAuth.Authentication.InMemory\CodeBeam.UltimateAuth.Authentication.InMemory.csproj" />
1819
<ProjectReference Include="..\..\..\src\authorization\CodeBeam.UltimateAuth.Authorization.InMemory\CodeBeam.UltimateAuth.Authorization.InMemory.csproj" />
1920
<ProjectReference Include="..\..\..\src\authorization\CodeBeam.UltimateAuth.Authorization.Reference\CodeBeam.UltimateAuth.Authorization.Reference.csproj" />
2021
<ProjectReference Include="..\..\..\src\authorization\CodeBeam.UltimateAuth.Authorization\CodeBeam.UltimateAuth.Authorization.csproj" />

samples/blazor-server/CodeBeam.UltimateAuth.Sample.BlazorServer/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using CodeBeam.UltimateAuth.Authentication.InMemory;
12
using CodeBeam.UltimateAuth.Authorization.InMemory.Extensions;
23
using CodeBeam.UltimateAuth.Authorization.Reference.Extensions;
34
using CodeBeam.UltimateAuth.Client;
@@ -57,6 +58,7 @@
5758
.AddUltimateAuthAuthorizationReference()
5859
.AddUltimateAuthInMemorySessions()
5960
.AddUltimateAuthInMemoryTokens()
61+
.AddUltimateAuthInMemoryAuthenticationSecurity()
6062
.AddUltimateAuthArgon2();
6163

6264
builder.Services.AddUltimateAuthClient(o =>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using CodeBeam.UltimateAuth.Core.Domain;
2+
using CodeBeam.UltimateAuth.Core.MultiTenancy;
3+
using CodeBeam.UltimateAuth.Core.Security;
4+
5+
namespace CodeBeam.UltimateAuth.Core.Abstractions;
6+
7+
public interface IAuthenticationSecurityManager
8+
{
9+
Task<AuthenticationSecurityState> GetOrCreateAccountAsync(TenantKey tenant, UserKey userKey, CancellationToken ct = default);
10+
Task<AuthenticationSecurityState> GetOrCreateFactorAsync(TenantKey tenant, UserKey userKey, CredentialType type, CancellationToken ct = default);
11+
Task<AuthenticationSecurityState> RegisterFailureAsync(AuthenticationSecurityState state, DateTimeOffset now, CancellationToken ct = default);
12+
Task<AuthenticationSecurityState> RegisterSuccessAsync(AuthenticationSecurityState state, CancellationToken ct = default);
13+
Task<AuthenticationSecurityState> UnlockAsync(AuthenticationSecurityState state, CancellationToken ct = default);
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using CodeBeam.UltimateAuth.Core.Domain;
2+
using CodeBeam.UltimateAuth.Core.MultiTenancy;
3+
using CodeBeam.UltimateAuth.Core.Security;
4+
5+
namespace CodeBeam.UltimateAuth.Core.Abstractions;
6+
7+
public interface IAuthenticationSecurityStateStore
8+
{
9+
Task<AuthenticationSecurityState?> GetAsync(TenantKey tenant, UserKey userKey, AuthenticationSecurityScope scope, CredentialType? credentialType, CancellationToken ct = default);
10+
11+
Task AddAsync(AuthenticationSecurityState state, CancellationToken ct = default);
12+
13+
Task UpdateAsync(AuthenticationSecurityState state, long expectedVersion, CancellationToken ct = default);
14+
}

src/CodeBeam.UltimateAuth.Core/Contracts/Login/LoginRequest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public sealed record LoginRequest
88
public TenantKey Tenant { get; init; }
99
public string Identifier { get; init; } = default!;
1010
public string Secret { get; init; } = default!;
11+
public CredentialType Factor { get; init; } = CredentialType.Password;
1112
public DateTimeOffset? At { get; init; }
1213
public IReadOnlyDictionary<string, string>? Metadata { get; init; }
1314

src/CodeBeam.UltimateAuth.Core/Domain/Principals/CredentialKind.cs renamed to src/CodeBeam.UltimateAuth.Core/Domain/Principals/GrantKind.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace CodeBeam.UltimateAuth.Core.Domain;
22

3-
public enum CredentialKind
3+
public enum GrantKind
44
{
55
Session,
66
AccessToken,

src/CodeBeam.UltimateAuth.Core/Domain/Principals/PrimaryCredentialKind.cs renamed to src/CodeBeam.UltimateAuth.Core/Domain/Principals/PrimaryGrantKind.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace CodeBeam.UltimateAuth.Core.Domain;
22

3-
public enum PrimaryCredentialKind
3+
public enum PrimaryGrantKind
44
{
55
Stateful,
66
Stateless

0 commit comments

Comments
 (0)