Skip to content

Commit 9249937

Browse files
committed
UX / Password has registration / Configuration.
1 parent c222b54 commit 9249937

25 files changed

Lines changed: 162 additions & 89 deletions
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
using Microsoft.EntityFrameworkCore;
2+
using Microsoft.Extensions.Options;
3+
using Shuttle.Mediator;
4+
using Shuttle.Recall.SqlServer.EventProcessing;
5+
using Shuttle.Recall.SqlServer.Storage;
6+
using System.Diagnostics.CodeAnalysis;
7+
using Shuttle.Recall;
8+
9+
namespace Shuttle.Access.Application;
10+
11+
[SuppressMessage("Security", "EF1002:Risk of vulnerability to SQL injection", Justification = "Schema and table names are from trusted configuration sources")]
12+
public class GetEventSourcingCountsParticipant(IOptions<SqlServerStorageOptions> sqlServerStorageOptions, IEventProcessorConfiguration eventProcessorConfiguration, SqlServerStorageDbContext sqlServerStorageDbContext, SqlServerEventProcessingDbContext sqlServerEventProcessingDbContext) : IParticipant<GetEventSourcingCounts>
13+
{
14+
public async Task HandleAsync(GetEventSourcingCounts message, CancellationToken cancellationToken = default)
15+
{
16+
ArgumentNullException.ThrowIfNull(message);
17+
18+
message.MaximumSequenceNumber = await sqlServerStorageDbContext.Database
19+
.SqlQueryRaw<long?>($@"SELECT MAX(SequenceNumber) [Value] FROM [{sqlServerStorageOptions.Value.Schema}].[PrimitiveEvent]")
20+
.SingleAsync(cancellationToken) ?? 0;
21+
22+
var projectionCount = await sqlServerEventProcessingDbContext.Database
23+
.SqlQueryRaw<int>($@"SELECT COUNT(*) [Value] FROM [{sqlServerStorageOptions.Value.Schema}].[Projection]")
24+
.SingleAsync(cancellationToken);
25+
26+
message.HasUnsequencedPrimitiveEvents = await sqlServerStorageDbContext.Database.SqlQueryRaw<int>($@"
27+
SELECT
28+
CASE
29+
WHEN EXISTS
30+
(
31+
SELECT
32+
NULL
33+
FROM
34+
[{sqlServerStorageOptions.Value.Schema}].[PrimitiveEvent]
35+
WHERE
36+
SequenceNumber IS NULL
37+
)
38+
THEN
39+
1
40+
ELSE
41+
0
42+
END [VALUE]
43+
").SingleAsync(cancellationToken) > 0;
44+
45+
message.HasWaitingProjections = projectionCount != eventProcessorConfiguration.Projections.Count() ||
46+
await sqlServerEventProcessingDbContext.Database.SqlQueryRaw<int>($@"
47+
SELECT
48+
CASE
49+
WHEN EXISTS
50+
(
51+
SELECT
52+
NULL
53+
FROM
54+
[{sqlServerStorageOptions.Value.Schema}].[Projection]
55+
WHERE
56+
[SequenceNumber] < {message.MaximumSequenceNumber}
57+
)
58+
THEN
59+
1
60+
ELSE
61+
0
62+
END [VALUE]
63+
").SingleAsync(cancellationToken) == 1;
64+
}
65+
}

Shuttle.Access.Application/Messages/ConfigureApplication.cs

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace Shuttle.Access.Application;
2+
3+
public class GetEventSourcingCounts
4+
{
5+
public long MaximumSequenceNumber { get; set; }
6+
public bool HasUnsequencedPrimitiveEvents { get; set; }
7+
public bool HasWaitingProjections { get; set; }
8+
}

Shuttle.Access.Application/Shuttle.Access.Application.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<PackageReference Include="Shuttle.Mediator" Version="21.0.1" />
1212
<PackageReference Include="Shuttle.Hopper" Version="21.0.2" />
1313
<PackageReference Include="Shuttle.Recall" Version="21.0.3" />
14+
<PackageReference Include="Shuttle.Recall.SqlServer.EventProcessing" Version="21.0.3" />
1415
<PackageReference Include="Shuttle.Recall.SqlServer.Storage" Version="21.0.3" />
1516
</ItemGroup>
1617

@@ -31,7 +32,7 @@
3132

3233
<PropertyGroup>
3334
<Description>Application concern implementations such as Shuttle.Mediator participants.</Description>
34-
<Version>9.0.3</Version>
35+
<Version>9.0.4</Version>
3536
<Authors>Eben Roux</Authors>
3637
<Company>Shuttle</Company>
3738
<Copyright>Copyright (c) 2025, Eben Roux</Copyright>

Shuttle.Access.AspNetCore/Shuttle.Access.AspNetCore.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
<PropertyGroup>
3535
<Description>Authorization middleware for web API endpoints using Shuttle.Access.</Description>
36-
<Version>9.0.2</Version>
36+
<Version>9.0.4</Version>
3737
<Authors>Eben Roux</Authors>
3838
<Company>Shuttle</Company>
3939
<Copyright>Copyright (c) 2025, Eben Roux</Copyright>

Shuttle.Access.Messages/Shuttle.Access.Messages.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
<PropertyGroup>
2929
<Description>Messages for use in Shuttle.Access implementations.</Description>
30-
<Version>9.0.2</Version>
30+
<Version>9.0.4</Version>
3131
<Authors>Eben Roux</Authors>
3232
<Company>Shuttle</Company>
3333
<Copyright>Copyright (c) 2025, Eben Roux</Copyright>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
namespace Shuttle.Access.Messages.v1;
2+
3+
public class ConfigureApplication;

Shuttle.Access.RestClient/AccessClientBuilderExtensions.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,18 @@ public AccessClientBuilder UseBearerAuthenticationProvider(Action<BearerAuthenti
4040
return accessClientBuilder;
4141
}
4242

43-
public AccessClientBuilder UsePasswordAuthenticationProvider(Action<PasswordAuthenticationInterceptorBuilder>? builder = null)
43+
public AccessClientBuilder UsePasswordAuthenticationProvider(Action<PasswordAuthenticationInterceptorOptions>? configureOptions = null)
4444
{
4545
var services = Guard.AgainstNull(accessClientBuilder).Services;
4646

4747
services.AddHttpClient<IAuthenticationInterceptor, PasswordAuthenticationInterceptor>("PasswordAuthenticationProvider");
4848

49-
var passwordAuthenticationProviderBuilder = new PasswordAuthenticationInterceptorBuilder(accessClientBuilder.Services);
50-
51-
builder?.Invoke(passwordAuthenticationProviderBuilder);
52-
53-
passwordAuthenticationProviderBuilder.Services
54-
.Configure<PasswordAuthenticationInterceptorOptions>(options =>
55-
{
56-
options.IdentityName = passwordAuthenticationProviderBuilder.Options.IdentityName;
57-
options.Password = passwordAuthenticationProviderBuilder.Options.Password;
58-
});
49+
services.Configure<PasswordAuthenticationInterceptorOptions>(options =>
50+
{
51+
configureOptions?.Invoke(options);
52+
});
5953

60-
passwordAuthenticationProviderBuilder.Services.AddSingleton<IValidateOptions<PasswordAuthenticationInterceptorOptions>, PasswordAuthenticationInterceptorOptionsValidator>();
54+
services.AddSingleton<IValidateOptions<PasswordAuthenticationInterceptorOptions>, PasswordAuthenticationInterceptorOptionsValidator>();
6155

6256
services.AddOptions<AccessClientOptions>().Configure(options =>
6357
{

Shuttle.Access.RestClient/PasswordAuthenticationInterceptorBuilder.cs

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

Shuttle.Access.RestClient/Shuttle.Access.RestClient.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
<PropertyGroup>
3535
<Description>A client used to interact with the restful Shuttle.Access web API.</Description>
36-
<Version>9.0.2</Version>
36+
<Version>9.0.4</Version>
3737
<Authors>Eben Roux</Authors>
3838
<Company>Shuttle</Company>
3939
<Copyright>Copyright (c) 2025, Eben Roux</Copyright>

0 commit comments

Comments
 (0)