Skip to content

Commit

Permalink
Moved the EventBus to Infrastructure and upgraded NuGet packages. (#53)
Browse files Browse the repository at this point in the history
* Moved the EventBus to Infrastructure and upgraded NuGet packages.

* Removed vars.
  • Loading branch information
Utar94 authored Mar 4, 2024
1 parent 9fb6917 commit 8d9bac6
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 33 deletions.
4 changes: 2 additions & 2 deletions src/Logitar.Identity.Domain/Logitar.Identity.Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@

<ItemGroup>
<PackageReference Include="FluentValidation" Version="11.9.0" />
<PackageReference Include="libphonenumber-csharp" Version="8.13.30" />
<PackageReference Include="libphonenumber-csharp" Version="8.13.31" />
<PackageReference Include="Logitar.EventSourcing" Version="5.0.1" />
<PackageReference Include="Logitar.Security" Version="6.1.1" />
<PackageReference Include="MediatR.Contracts" Version="2.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="7.3.1" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="7.4.0" />
<PackageReference Include="NodaTime" Version="3.1.11" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
using Logitar.EventSourcing.EntityFrameworkCore.Relational;
using Logitar.EventSourcing.Infrastructure;
using Logitar.Identity.Domain.ApiKeys;
using Logitar.Identity.Domain.Passwords;
using Logitar.Identity.Domain.Roles;
using Logitar.Identity.Domain.Sessions;
using Logitar.Identity.Domain.Tokens;
using Logitar.Identity.Domain.Users;
using Logitar.Identity.EntityFrameworkCore.Relational.CustomAttributes;
using Logitar.Identity.EntityFrameworkCore.Relational.Handlers.ApiKeys;
using Logitar.Identity.EntityFrameworkCore.Relational.Handlers.Passwords;
using Logitar.Identity.EntityFrameworkCore.Relational.Handlers.Roles;
using Logitar.Identity.EntityFrameworkCore.Relational.Handlers.Sessions;
using Logitar.Identity.EntityFrameworkCore.Relational.Handlers.Users;
using Logitar.Identity.EntityFrameworkCore.Relational.Handlers;
using Logitar.Identity.EntityFrameworkCore.Relational.Repositories;
using Logitar.Identity.EntityFrameworkCore.Relational.Tokens;
using Logitar.Identity.Infrastructure;
using Logitar.Identity.Infrastructure.Handlers;
using Microsoft.Extensions.DependencyInjection;

namespace Logitar.Identity.EntityFrameworkCore.Relational;
Expand All @@ -30,7 +26,6 @@ public static IServiceCollection AddLogitarIdentityWithEntityFrameworkCoreRelati
.AddMediatR(config => config.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly()))
.AddRepositories()
.AddTransient<ICustomAttributeService, CustomAttributeService>()
.AddTransient<IEventBus, EventBus>()
.AddTransient<ITokenBlacklist, TokenBlacklist>();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
using Logitar.Identity.Domain.ApiKeys.Events;
using Logitar.Identity.EntityFrameworkCore.Relational.CustomAttributes;
using Logitar.Identity.EntityFrameworkCore.Relational.Entities;
using Logitar.Identity.Infrastructure.Handlers;
using Microsoft.EntityFrameworkCore;

namespace Logitar.Identity.EntityFrameworkCore.Relational.Handlers.ApiKeys;
namespace Logitar.Identity.EntityFrameworkCore.Relational.Handlers;

public class ApiKeyEventHandler : IApiKeyEventHandler
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
using Logitar.Identity.Domain.Passwords.Events;
using Logitar.Identity.EntityFrameworkCore.Relational.CustomAttributes;
using Logitar.Identity.EntityFrameworkCore.Relational.Entities;
using Logitar.Identity.Infrastructure.Handlers;
using Microsoft.EntityFrameworkCore;

namespace Logitar.Identity.EntityFrameworkCore.Relational.Handlers.Passwords;
namespace Logitar.Identity.EntityFrameworkCore.Relational.Handlers;

public class OneTimePasswordEventHandler : IOneTimePasswordEventHandler
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
using Logitar.Identity.Domain.Roles.Events;
using Logitar.Identity.EntityFrameworkCore.Relational.CustomAttributes;
using Logitar.Identity.EntityFrameworkCore.Relational.Entities;
using Logitar.Identity.Infrastructure.Handlers;
using Microsoft.EntityFrameworkCore;

namespace Logitar.Identity.EntityFrameworkCore.Relational.Handlers.Roles;
namespace Logitar.Identity.EntityFrameworkCore.Relational.Handlers;

public class RoleEventHandler : IRoleEventHandler
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
using Logitar.Identity.Domain.Sessions.Events;
using Logitar.Identity.EntityFrameworkCore.Relational.CustomAttributes;
using Logitar.Identity.EntityFrameworkCore.Relational.Entities;
using Logitar.Identity.Infrastructure.Handlers;
using Microsoft.EntityFrameworkCore;

namespace Logitar.Identity.EntityFrameworkCore.Relational.Handlers.Sessions;
namespace Logitar.Identity.EntityFrameworkCore.Relational.Handlers;

public class SessionEventHandler : ISessionEventHandler
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
using Logitar.Identity.Domain.Users.Events;
using Logitar.Identity.EntityFrameworkCore.Relational.CustomAttributes;
using Logitar.Identity.EntityFrameworkCore.Relational.Entities;
using Logitar.Identity.Infrastructure.Handlers;
using Microsoft.EntityFrameworkCore;

namespace Logitar.Identity.EntityFrameworkCore.Relational.Handlers.Users;
namespace Logitar.Identity.EntityFrameworkCore.Relational.Handlers;

public class UserEventHandler : IUserEventHandler
{
Expand Down Expand Up @@ -152,8 +153,8 @@ public virtual async Task HandleAsync(UserRoleAddedEvent @event, CancellationTok
if (user != null)
{
RoleEntity role = await Context.Roles
.SingleOrDefaultAsync(x => x.AggregateId == @event.RoleId.AggregateId.Value, cancellationToken)
?? throw new InvalidOperationException($"The role entity 'AggregateId={@event.AggregateId}' could not be found.");
.SingleOrDefaultAsync(x => x.AggregateId == @event.RoleId.AggregateId.Value, cancellationToken)
?? throw new InvalidOperationException($"The role entity 'AggregateId={@event.AggregateId}' could not be found.");

user.AddRole(role, @event);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
<ItemGroup>
<PackageReference Include="Logitar.Data" Version="3.0.0" />
<PackageReference Include="Logitar.EventSourcing.EntityFrameworkCore.Relational" Version="5.0.1" />
<PackageReference Include="MediatR" Version="12.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ public static IServiceCollection AddLogitarIdentityInfrastructure(this IServiceC
IConfiguration configuration = serviceProvider.GetRequiredService<IConfiguration>();
return configuration.GetSection("Pbkdf2").Get<Pbkdf2Settings>() ?? new();
})
.AddTransient<IEventBus, EventBus>()
.AddTransient<ITokenManager, JsonWebTokenManager>();
}

public static IEnumerable<JsonConverter> GetLogitarIdentityJsonConverters(this IServiceProvider serviceProvider) => new JsonConverter[]
{
public static IEnumerable<JsonConverter> GetLogitarIdentityJsonConverters(this IServiceProvider serviceProvider) =>
[
serviceProvider.GetRequiredService<PasswordConverter>(),
new ApiKeyIdConverter(),
new DescriptionConverter(),
Expand All @@ -47,7 +48,7 @@ public static IServiceCollection AddLogitarIdentityInfrastructure(this IServiceC
new UniqueNameConverter(),
new UrlConverter(),
new UserIdConverter()
};
];

private static IServiceCollection AddPasswordStrategies(this IServiceCollection services)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@
using Logitar.Identity.Domain.Roles.Events;
using Logitar.Identity.Domain.Sessions.Events;
using Logitar.Identity.Domain.Users.Events;
using Logitar.Identity.EntityFrameworkCore.Relational.Handlers.ApiKeys;
using Logitar.Identity.EntityFrameworkCore.Relational.Handlers.Passwords;
using Logitar.Identity.EntityFrameworkCore.Relational.Handlers.Roles;
using Logitar.Identity.EntityFrameworkCore.Relational.Handlers.Sessions;
using Logitar.Identity.EntityFrameworkCore.Relational.Handlers.Users;
using Logitar.Identity.Infrastructure.Handlers;
using MediatR;

namespace Logitar.Identity.EntityFrameworkCore.Relational;
namespace Logitar.Identity.Infrastructure;

public class EventBus : IEventBus
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Logitar.Identity.Domain.ApiKeys.Events;

namespace Logitar.Identity.EntityFrameworkCore.Relational.Handlers.ApiKeys;
namespace Logitar.Identity.Infrastructure.Handlers;

public interface IApiKeyEventHandler
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Logitar.Identity.Domain.Passwords.Events;

namespace Logitar.Identity.EntityFrameworkCore.Relational.Handlers.Passwords;
namespace Logitar.Identity.Infrastructure.Handlers;

public interface IOneTimePasswordEventHandler
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Logitar.Identity.Domain.Roles.Events;

namespace Logitar.Identity.EntityFrameworkCore.Relational.Handlers.Roles;
namespace Logitar.Identity.Infrastructure.Handlers;

public interface IRoleEventHandler
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Logitar.Identity.Domain.Sessions.Events;

namespace Logitar.Identity.EntityFrameworkCore.Relational.Handlers.Sessions;
namespace Logitar.Identity.Infrastructure.Handlers;

public interface ISessionEventHandler
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Logitar.Identity.Domain.Users.Events;

namespace Logitar.Identity.EntityFrameworkCore.Relational.Handlers.Users;
namespace Logitar.Identity.Infrastructure.Handlers;

public interface IUserEventHandler
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@

<ItemGroup>
<PackageReference Include="Logitar.EventSourcing.Infrastructure" Version="5.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="8.0.1" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.3.1" />
<PackageReference Include="MediatR" Version="12.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="8.0.2" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.4.0" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 8d9bac6

Please sign in to comment.