-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
418 additions
and
8 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
lib/Logitar.Identity.EntityFrameworkCore.Relational/DependencyInjectionExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using Logitar.EventSourcing.EntityFrameworkCore.Relational; | ||
using Logitar.Identity.Core.ApiKeys; | ||
using Logitar.Identity.Core.Passwords; | ||
using Logitar.Identity.Core.Roles; | ||
using Logitar.Identity.Core.Sessions; | ||
using Logitar.Identity.Core.Tokens; | ||
using Logitar.Identity.Core.Users; | ||
using Logitar.Identity.EntityFrameworkCore.Relational.Repositories; | ||
using Logitar.Identity.EntityFrameworkCore.Relational.Tokens; | ||
using Logitar.Identity.Infrastructure; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace Logitar.Identity.EntityFrameworkCore.Relational; | ||
|
||
public static class DependencyInjectionExtensions | ||
{ | ||
public static IServiceCollection AddLogitarIdentityWithEntityFrameworkCoreRelational(this IServiceCollection services) | ||
{ | ||
return services | ||
.AddLogitarEventSourcingWithEntityFrameworkCoreRelational() | ||
.AddLogitarIdentityInfrastructure() | ||
.AddEventHandlers() | ||
.AddMediatR(config => config.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly())) | ||
.AddRepositories() | ||
//.AddTransient<ICustomAttributeService, CustomAttributeService>() // TODO(fpion): implement | ||
.AddScoped<ITokenBlacklist, TokenBlacklist>(); | ||
} | ||
|
||
private static IServiceCollection AddEventHandlers(this IServiceCollection services) | ||
{ | ||
return services/* | ||
.AddTransient<IApiKeyEventHandler, ApiKeyEventHandler>() | ||
.AddTransient<IOneTimePasswordEventHandler, OneTimePasswordEventHandler>() | ||
.AddTransient<IRoleEventHandler, RoleEventHandler>() | ||
.AddTransient<ISessionEventHandler, SessionEventHandler>() | ||
.AddTransient<IUserEventHandler, UserEventHandler>()*/; // TODO(fpion): implement | ||
} | ||
|
||
private static IServiceCollection AddRepositories(this IServiceCollection services) | ||
{ | ||
return services | ||
.AddScoped<IApiKeyRepository, ApiKeyRepository>() | ||
.AddScoped<IOneTimePasswordRepository, OneTimePasswordRepository>() | ||
.AddScoped<IRoleRepository, RoleRepository>() | ||
.AddScoped<ISessionRepository, SessionRepository>() | ||
.AddScoped<IUserRepository, UserRepository>(); | ||
} | ||
} |
4 changes: 1 addition & 3 deletions
4
lib/Logitar.Identity.EntityFrameworkCore.Relational/Entities/ActorEntity.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
lib/Logitar.Identity.EntityFrameworkCore.Relational/Entities/OneTimePasswordEntity.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
lib/Logitar.Identity.EntityFrameworkCore.Relational/Entities/RoleEntity.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
lib/Logitar.Identity.EntityFrameworkCore.Relational/Repositories/ApiKeyRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using Logitar.EventSourcing; | ||
using Logitar.Identity.Core; | ||
using Logitar.Identity.Core.ApiKeys; | ||
using Logitar.Identity.Core.Roles; | ||
|
||
namespace Logitar.Identity.EntityFrameworkCore.Relational.Repositories; | ||
|
||
public class ApiKeyRepository : Repository, IApiKeyRepository | ||
{ | ||
public ApiKeyRepository(IEventStore eventStore) : base(eventStore) | ||
{ | ||
} | ||
|
||
public async Task<ApiKey?> LoadAsync(ApiKeyId id, CancellationToken cancellationToken) | ||
{ | ||
return await LoadAsync(id, isDeleted: null, cancellationToken); | ||
} | ||
public async Task<ApiKey?> LoadAsync(ApiKeyId id, long? version, CancellationToken cancellationToken) | ||
{ | ||
return await LoadAsync(id, version, isDeleted: null, cancellationToken); | ||
} | ||
public async Task<ApiKey?> LoadAsync(ApiKeyId id, bool? isDeleted, CancellationToken cancellationToken) | ||
{ | ||
return await LoadAsync(id, version: null, isDeleted, cancellationToken); | ||
} | ||
public async Task<ApiKey?> LoadAsync(ApiKeyId id, long? version, bool? isDeleted, CancellationToken cancellationToken) | ||
{ | ||
return await LoadAsync<ApiKey>(id.StreamId, version, isDeleted, cancellationToken); | ||
} | ||
|
||
public async Task<IReadOnlyCollection<ApiKey>> LoadAsync(CancellationToken cancellationToken) | ||
{ | ||
return await LoadAsync(isDeleted: null, cancellationToken); | ||
} | ||
public async Task<IReadOnlyCollection<ApiKey>> LoadAsync(bool? isDeleted, CancellationToken cancellationToken) | ||
{ | ||
return await LoadAsync<ApiKey>(isDeleted, cancellationToken); | ||
} | ||
|
||
public async Task<IReadOnlyCollection<ApiKey>> LoadAsync(IEnumerable<ApiKeyId> ids, CancellationToken cancellationToken) | ||
{ | ||
return await LoadAsync(ids, isDeleted: null, cancellationToken); | ||
} | ||
public async Task<IReadOnlyCollection<ApiKey>> LoadAsync(IEnumerable<ApiKeyId> ids, bool? isDeleted, CancellationToken cancellationToken) | ||
{ | ||
IEnumerable<StreamId> streamIds = ids.Select(id => id.StreamId); | ||
return await LoadAsync<ApiKey>(streamIds, isDeleted, cancellationToken); | ||
} | ||
|
||
public Task<IReadOnlyCollection<ApiKey>> LoadAsync(TenantId? tenantId, CancellationToken cancellationToken) | ||
{ | ||
throw new NotImplementedException(); // TODO(fpion): implement | ||
} | ||
|
||
public Task<IReadOnlyCollection<ApiKey>> LoadAsync(Role role, CancellationToken cancellationToken) | ||
{ | ||
throw new NotImplementedException(); // TODO(fpion): implement | ||
} | ||
|
||
public async Task SaveAsync(ApiKey apikey, CancellationToken cancellationToken) | ||
{ | ||
await base.SaveAsync(apikey, cancellationToken); | ||
} | ||
public async Task SaveAsync(IEnumerable<ApiKey> apikeys, CancellationToken cancellationToken) | ||
{ | ||
await base.SaveAsync(apikeys, cancellationToken); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
...Logitar.Identity.EntityFrameworkCore.Relational/Repositories/OneTimePasswordRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using Logitar.EventSourcing; | ||
using Logitar.Identity.Core; | ||
using Logitar.Identity.Core.Passwords; | ||
|
||
namespace Logitar.Identity.EntityFrameworkCore.Relational.Repositories; | ||
|
||
public class OneTimePasswordRepository : Repository, IOneTimePasswordRepository | ||
{ | ||
public OneTimePasswordRepository(IEventStore eventStore) : base(eventStore) | ||
{ | ||
} | ||
|
||
public async Task<OneTimePassword?> LoadAsync(OneTimePasswordId id, CancellationToken cancellationToken) | ||
{ | ||
return await LoadAsync(id, isDeleted: null, cancellationToken); | ||
} | ||
public async Task<OneTimePassword?> LoadAsync(OneTimePasswordId id, long? version, CancellationToken cancellationToken) | ||
{ | ||
return await LoadAsync(id, version, isDeleted: null, cancellationToken); | ||
} | ||
public async Task<OneTimePassword?> LoadAsync(OneTimePasswordId id, bool? isDeleted, CancellationToken cancellationToken) | ||
{ | ||
return await LoadAsync(id, version: null, isDeleted, cancellationToken); | ||
} | ||
public async Task<OneTimePassword?> LoadAsync(OneTimePasswordId id, long? version, bool? isDeleted, CancellationToken cancellationToken) | ||
{ | ||
return await LoadAsync<OneTimePassword>(id.StreamId, version, isDeleted, cancellationToken); | ||
} | ||
|
||
public async Task<IReadOnlyCollection<OneTimePassword>> LoadAsync(CancellationToken cancellationToken) | ||
{ | ||
return await LoadAsync(isDeleted: null, cancellationToken); | ||
} | ||
public async Task<IReadOnlyCollection<OneTimePassword>> LoadAsync(bool? isDeleted, CancellationToken cancellationToken) | ||
{ | ||
return await LoadAsync<OneTimePassword>(isDeleted, cancellationToken); | ||
} | ||
|
||
public async Task<IReadOnlyCollection<OneTimePassword>> LoadAsync(IEnumerable<OneTimePasswordId> ids, CancellationToken cancellationToken) | ||
{ | ||
return await LoadAsync(ids, isDeleted: null, cancellationToken); | ||
} | ||
public async Task<IReadOnlyCollection<OneTimePassword>> LoadAsync(IEnumerable<OneTimePasswordId> ids, bool? isDeleted, CancellationToken cancellationToken) | ||
{ | ||
IEnumerable<StreamId> streamIds = ids.Select(id => id.StreamId); | ||
return await LoadAsync<OneTimePassword>(streamIds, isDeleted, cancellationToken); | ||
} | ||
|
||
public Task<IReadOnlyCollection<OneTimePassword>> LoadAsync(TenantId? tenantId, CancellationToken cancellationToken) | ||
{ | ||
throw new NotImplementedException(); // TODO(fpion): implement | ||
} | ||
|
||
public async Task SaveAsync(OneTimePassword onetimepassword, CancellationToken cancellationToken) | ||
{ | ||
await base.SaveAsync(onetimepassword, cancellationToken); | ||
} | ||
public async Task SaveAsync(IEnumerable<OneTimePassword> onetimepasswords, CancellationToken cancellationToken) | ||
{ | ||
await base.SaveAsync(onetimepasswords, cancellationToken); | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
lib/Logitar.Identity.EntityFrameworkCore.Relational/Repositories/RoleRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using Logitar.EventSourcing; | ||
using Logitar.Identity.Core; | ||
using Logitar.Identity.Core.ApiKeys; | ||
using Logitar.Identity.Core.Roles; | ||
using Logitar.Identity.Core.Users; | ||
|
||
namespace Logitar.Identity.EntityFrameworkCore.Relational.Repositories; | ||
|
||
public class RoleRepository : Repository, IRoleRepository | ||
{ | ||
public RoleRepository(IEventStore eventStore) : base(eventStore) | ||
{ | ||
} | ||
|
||
public async Task<Role?> LoadAsync(RoleId id, CancellationToken cancellationToken) | ||
{ | ||
return await LoadAsync(id, isDeleted: null, cancellationToken); | ||
} | ||
public async Task<Role?> LoadAsync(RoleId id, long? version, CancellationToken cancellationToken) | ||
{ | ||
return await LoadAsync(id, version, isDeleted: null, cancellationToken); | ||
} | ||
public async Task<Role?> LoadAsync(RoleId id, bool? isDeleted, CancellationToken cancellationToken) | ||
{ | ||
return await LoadAsync(id, version: null, isDeleted, cancellationToken); | ||
} | ||
public async Task<Role?> LoadAsync(RoleId id, long? version, bool? isDeleted, CancellationToken cancellationToken) | ||
{ | ||
return await LoadAsync<Role>(id.StreamId, version, isDeleted, cancellationToken); | ||
} | ||
|
||
public async Task<IReadOnlyCollection<Role>> LoadAsync(CancellationToken cancellationToken) | ||
{ | ||
return await LoadAsync(isDeleted: null, cancellationToken); | ||
} | ||
public async Task<IReadOnlyCollection<Role>> LoadAsync(bool? isDeleted, CancellationToken cancellationToken) | ||
{ | ||
return await LoadAsync<Role>(isDeleted, cancellationToken); | ||
} | ||
|
||
public async Task<IReadOnlyCollection<Role>> LoadAsync(IEnumerable<RoleId> ids, CancellationToken cancellationToken) | ||
{ | ||
return await LoadAsync(ids, isDeleted: null, cancellationToken); | ||
} | ||
public async Task<IReadOnlyCollection<Role>> LoadAsync(IEnumerable<RoleId> ids, bool? isDeleted, CancellationToken cancellationToken) | ||
{ | ||
IEnumerable<StreamId> streamIds = ids.Select(id => id.StreamId); | ||
return await LoadAsync<Role>(streamIds, isDeleted, cancellationToken); | ||
} | ||
|
||
public Task<IReadOnlyCollection<Role>> LoadAsync(TenantId? tenantId, CancellationToken cancellationToken) | ||
{ | ||
throw new NotImplementedException(); // TODO(fpion): implement | ||
} | ||
|
||
public Task<Role?> LoadAsync(TenantId? tenantId, UniqueName uniqueName, CancellationToken cancellationToken) | ||
{ | ||
throw new NotImplementedException(); // TODO(fpion): implement | ||
} | ||
|
||
public Task<IReadOnlyCollection<Role>> LoadAsync(ApiKey apiKey, CancellationToken cancellationToken) | ||
{ | ||
throw new NotImplementedException(); // TODO(fpion): implement | ||
} | ||
public Task<IReadOnlyCollection<Role>> LoadAsync(User user, CancellationToken cancellationToken) | ||
{ | ||
throw new NotImplementedException(); // TODO(fpion): implement | ||
} | ||
|
||
public async Task SaveAsync(Role role, CancellationToken cancellationToken) | ||
{ | ||
await base.SaveAsync(role, cancellationToken); | ||
} | ||
public async Task SaveAsync(IEnumerable<Role> roles, CancellationToken cancellationToken) | ||
{ | ||
await base.SaveAsync(roles, cancellationToken); | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
lib/Logitar.Identity.EntityFrameworkCore.Relational/Repositories/SessionRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using Logitar.EventSourcing; | ||
using Logitar.Identity.Core; | ||
using Logitar.Identity.Core.Sessions; | ||
using Logitar.Identity.Core.Users; | ||
|
||
namespace Logitar.Identity.EntityFrameworkCore.Relational.Repositories; | ||
|
||
public class SessionRepository : Repository, ISessionRepository | ||
{ | ||
public SessionRepository(IEventStore eventStore) : base(eventStore) | ||
{ | ||
} | ||
|
||
public async Task<Session?> LoadAsync(SessionId id, CancellationToken cancellationToken) | ||
{ | ||
return await LoadAsync(id, isDeleted: null, cancellationToken); | ||
} | ||
public async Task<Session?> LoadAsync(SessionId id, long? version, CancellationToken cancellationToken) | ||
{ | ||
return await LoadAsync(id, version, isDeleted: null, cancellationToken); | ||
} | ||
public async Task<Session?> LoadAsync(SessionId id, bool? isDeleted, CancellationToken cancellationToken) | ||
{ | ||
return await LoadAsync(id, version: null, isDeleted, cancellationToken); | ||
} | ||
public async Task<Session?> LoadAsync(SessionId id, long? version, bool? isDeleted, CancellationToken cancellationToken) | ||
{ | ||
return await LoadAsync<Session>(id.StreamId, version, isDeleted, cancellationToken); | ||
} | ||
|
||
public async Task<IReadOnlyCollection<Session>> LoadAsync(CancellationToken cancellationToken) | ||
{ | ||
return await LoadAsync(isDeleted: null, cancellationToken); | ||
} | ||
public async Task<IReadOnlyCollection<Session>> LoadAsync(bool? isDeleted, CancellationToken cancellationToken) | ||
{ | ||
return await LoadAsync<Session>(isDeleted, cancellationToken); | ||
} | ||
|
||
public async Task<IReadOnlyCollection<Session>> LoadAsync(IEnumerable<SessionId> ids, CancellationToken cancellationToken) | ||
{ | ||
return await LoadAsync(ids, isDeleted: null, cancellationToken); | ||
} | ||
public async Task<IReadOnlyCollection<Session>> LoadAsync(IEnumerable<SessionId> ids, bool? isDeleted, CancellationToken cancellationToken) | ||
{ | ||
IEnumerable<StreamId> streamIds = ids.Select(id => id.StreamId); | ||
return await LoadAsync<Session>(streamIds, isDeleted, cancellationToken); | ||
} | ||
|
||
public Task<IReadOnlyCollection<Session>> LoadAsync(TenantId? tenantId, CancellationToken cancellationToken) | ||
{ | ||
throw new NotImplementedException(); // TODO(fpion): implement | ||
} | ||
|
||
public Task<IReadOnlyCollection<Session>> LoadActiveAsync(User user, CancellationToken cancellationToken) | ||
{ | ||
throw new NotImplementedException(); // TODO(fpion): implement | ||
} | ||
public Task<IReadOnlyCollection<Session>> LoadAsync(User user, CancellationToken cancellationToken) | ||
{ | ||
throw new NotImplementedException(); // TODO(fpion): implement | ||
} | ||
|
||
public async Task SaveAsync(Session session, CancellationToken cancellationToken) | ||
{ | ||
await base.SaveAsync(session, cancellationToken); | ||
} | ||
public async Task SaveAsync(IEnumerable<Session> sessions, CancellationToken cancellationToken) | ||
{ | ||
await base.SaveAsync(sessions, cancellationToken); | ||
} | ||
} |
Oops, something went wrong.