Skip to content

Commit 6871a14

Browse files
committed
- checkpoint
1 parent 15e2540 commit 6871a14

110 files changed

Lines changed: 2324 additions & 1345 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.

.dockerignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
**/.classpath
2+
**/.dockerignore
3+
**/.env
4+
**/.git
5+
**/.gitignore
6+
**/.project
7+
**/.settings
8+
**/.toolstarget
9+
**/.vs
10+
**/.vscode
11+
**/*.*proj.user
12+
**/*.dbmdl
13+
**/*.jfm
14+
**/azds.yaml
15+
**/bin
16+
**/charts
17+
**/docker-compose*
18+
**/Dockerfile*
19+
**/node_modules
20+
**/npm-debug.log
21+
**/obj
22+
**/secrets.dev.yaml
23+
**/values.dev.yaml
24+
LICENSE
25+
README.md
26+
!**/.gitignore
27+
!.git/HEAD
28+
!.git/config
29+
!.git/packed-refs
30+
!.git/refs/heads/**

Shuttle.Access.Application/ChangePasswordParticipant.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public void ProcessMessage(IParticipantContext<RequestMessage<ChangePassword>> c
4343

4444
if (request.Token.HasValue)
4545
{
46-
var session = _sessionRepository.Find(request.Token.Value);
46+
var session = _sessionRepository.FindAsync(request.Token.Value);
4747

4848
if (session == null)
4949
{

Shuttle.Access.Application/RegisterIdentityParticipant.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void ProcessMessage(IParticipantContext<RequestResponseMessage<RegisterId
4040
Identity identity;
4141

4242
var key = Identity.Key(message.Name);
43-
var id = _keyStore.Get(key);
43+
var id = _keyStore.Find(key);
4444

4545
if (id.HasValue)
4646
{
@@ -61,7 +61,7 @@ public void ProcessMessage(IParticipantContext<RequestResponseMessage<RegisterId
6161

6262
_keyStore.Add(id.Value, key);
6363

64-
stream = _eventStore.CreateEventStream(id.Value);
64+
stream = _eventStore.Get(id.Value);
6565
}
6666

6767
var registered = identity.Register(message.Name, message.PasswordHash, message.RegisteredBy, message.GeneratedPassword, message.Activated);

Shuttle.Access.Application/RegisterPermissionParticipant.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public void ProcessMessage(IParticipantContext<RequestResponseMessage<RegisterPe
3939
_keyStore.Add(id, key);
4040

4141
var aggregate = new Permission();
42-
var stream = _eventStore.CreateEventStream(id);
42+
var stream = _eventStore.Get(id);
4343
var status = message.Status;
4444

4545
if (!Enum.IsDefined(typeof(PermissionStatus), status))

Shuttle.Access.Application/RegisterRoleParticipant.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public void ProcessMessage(IParticipantContext<RequestResponseMessage<RegisterRo
3939
_keyStore.Add(id, key);
4040

4141
var role = new Role();
42-
var stream = _eventStore.CreateEventStream(id);
42+
var stream = _eventStore.Get(id);
4343

4444
stream.AddEvent(role.Register(message.Name));
4545

Shuttle.Access.Application/SessionIdentityRegistrationRequestedParticipant.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public void ProcessMessage(IParticipantContext<IdentityRegistrationRequested> co
2525
return;
2626
}
2727

28-
var session = _sessionRepository.Find(context.Message.SessionToken.Value);
28+
var session = _sessionRepository.FindAsync(context.Message.SessionToken.Value);
2929

3030
if (session != null && session.HasPermission(Permissions.Register.Identity))
3131
{

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project Sdk="Microsoft.NET.Sdk">
33

44
<PropertyGroup>
5-
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
5+
<TargetFramework>net8.0</TargetFramework>
66
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
77
</PropertyGroup>
88

@@ -16,10 +16,10 @@
1616

1717
<ItemGroup>
1818
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
19-
<PackageReference Include="Shuttle.Core.Contract" Version="11.0.0" />
20-
<PackageReference Include="Shuttle.Core.Mediator" Version="13.1.1" />
21-
<PackageReference Include="Shuttle.Recall" Version="16.1.1" />
22-
<PackageReference Include="Shuttle.Recall.Sql.Storage" Version="16.1.1" />
19+
<PackageReference Include="Shuttle.Core.Contract" Version="11.1.0" />
20+
<PackageReference Include="Shuttle.Core.Mediator" Version="14.0.0" />
21+
<PackageReference Include="Shuttle.Recall" Version="17.0.1" />
22+
<PackageReference Include="Shuttle.Recall.Sql.Storage" Version="17.0.1" />
2323
</ItemGroup>
2424

2525
<ItemGroup>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
using System;
2+
using Microsoft.Extensions.Options;
3+
using Shuttle.Core.Contract;
4+
using Shuttle.Core.Data;
5+
6+
namespace Shuttle.Access.Mvc.DataStore
7+
{
8+
public class DataStoreAccessService : CachedAccessService, IAccessService
9+
{
10+
private readonly AccessOptions _accessOptions;
11+
private readonly IDatabaseContextFactory _databaseContextFactory;
12+
private readonly ISessionRepository _sessionRepository;
13+
private readonly string _connectionStringName;
14+
15+
public DataStoreAccessService(IOptionsMonitor<ConnectionStringOptions> connectionStringOptions, IOptions<AccessOptions> accessOptions, IDatabaseContextFactory databaseContextFactory, ISessionRepository sessionRepository) {
16+
Guard.AgainstNull(connectionStringOptions, nameof(connectionStringOptions));
17+
Guard.AgainstNull(accessOptions, nameof(accessOptions));
18+
Guard.AgainstNull(accessOptions.Value, nameof(accessOptions.Value));
19+
Guard.AgainstNull(databaseContextFactory, nameof(databaseContextFactory));
20+
Guard.AgainstNull(sessionRepository, nameof(sessionRepository));
21+
22+
_accessOptions = accessOptions.Value;
23+
_connectionStringName = accessOptions.Value.ConnectionStringName;
24+
_databaseContextFactory = databaseContextFactory;
25+
_sessionRepository = sessionRepository;
26+
}
27+
28+
public new bool Contains(Guid token)
29+
{
30+
var result = base.Contains(token);
31+
32+
if (!result)
33+
{
34+
Cache(token);
35+
36+
return base.Contains(token);
37+
}
38+
39+
return true;
40+
}
41+
42+
public new bool HasPermission(Guid token, string permission)
43+
{
44+
if (!base.Contains(token))
45+
{
46+
Cache(token);
47+
}
48+
49+
return base.HasPermission(token, permission);
50+
}
51+
52+
public new void Remove(Guid token)
53+
{
54+
base.Remove(token);
55+
}
56+
57+
private void Cache(Guid token)
58+
{
59+
if (base.Contains(token))
60+
{
61+
return;
62+
}
63+
64+
using (_databaseContextFactory.Create(_connectionStringName))
65+
{
66+
var session = _sessionRepository.Find(token);
67+
68+
if (session != null)
69+
{
70+
Cache(token, session.Permissions, _accessOptions.SessionDuration);
71+
}
72+
}
73+
}
74+
}
75+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
using Microsoft.Extensions.DependencyInjection;
3+
using Microsoft.Extensions.DependencyInjection.Extensions;
4+
using Shuttle.Core.Contract;
5+
6+
namespace Shuttle.Access.Mvc.DataStore
7+
{
8+
public static class ServiceCollectionExtensions
9+
{
10+
public static IServiceCollection AddDataStoreAccessService(this IServiceCollection services)
11+
{
12+
Guard.AgainstNull(services, nameof(services));
13+
14+
services.TryAddSingleton<IAccessService, DataStoreAccessService>();
15+
16+
return services;
17+
}
18+
}
19+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<ProjectReference Include="..\Shuttle.Access\Shuttle.Access.csproj" />
11+
</ItemGroup>
12+
13+
</Project>

0 commit comments

Comments
 (0)