Skip to content

Commit

Permalink
build: update packages
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmet-cetinkaya committed Apr 2, 2024
1 parent ec014c6 commit a0cc8d5
Show file tree
Hide file tree
Showing 17 changed files with 45 additions and 39 deletions.
10 changes: 5 additions & 5 deletions src/starterProject/Application/Application.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
<ItemGroup>
<PackageReference Include="AutoMapper" Version="13.0.1" />
<PackageReference Include="MediatR" Version="12.2.0" />
<PackageReference Include="NArchitecture.Core.Application" Version="1.0.0" />
<PackageReference Include="NArchitecture.Core.Mailing" Version="1.0.0" />
<PackageReference Include="NArchitecture.Core.Mailing.Mailkit" Version="1.0.0" />
<PackageReference Include="NArchitecture.Core.Application" Version="1.0.1" />
<PackageReference Include="NArchitecture.Core.Mailing" Version="1.0.1" />
<PackageReference Include="NArchitecture.Core.Mailing.Mailkit" Version="1.0.1" />
<PackageReference Include="NArchitecture.Core.CrossCuttingConcerns.Exception" Version="1.0.0" />
<PackageReference Include="NArchitecture.Core.CrossCuttingConcerns.Logging.Serilog.File" Version="1.0.0" />
<PackageReference Include="NArchitecture.Core.Localization.Abstraction" Version="1.0.0" />
<PackageReference Include="NArchitecture.Core.Localization.Resource.Yaml.DependencyInjection" Version="1.0.0" />
<PackageReference Include="NArchitecture.Core.Localization.Resource.Yaml.DependencyInjection" Version="1.0.1" />
<PackageReference Include="NArchitecture.Core.ElasticSearch" Version="1.0.0" />
<PackageReference Include="NArchitecture.Core.Security.DependencyInjection" Version="1.0.0" />
<PackageReference Include="NArchitecture.Core.Security.DependencyInjection" Version="1.2.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Services\" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using NArchitecture.Core.Mailing;
using NArchitecture.Core.Mailing.MailKit;
using NArchitecture.Core.Security.DependencyInjection;
using NArchitecture.Core.Security.JWT;

namespace Application;

Expand All @@ -28,7 +29,8 @@ public static IServiceCollection AddApplicationServices(
this IServiceCollection services,
MailSettings mailSettings,
FileLogConfiguration fileLogConfiguration,
ElasticSearchConfig elasticSearchConfig
ElasticSearchConfig elasticSearchConfig,
TokenOptions tokenOptions
)
{
services.AddAutoMapper(Assembly.GetExecutingAssembly());
Expand Down Expand Up @@ -57,7 +59,7 @@ ElasticSearchConfig elasticSearchConfig

services.AddYamlResourceLocalization();

services.AddSecurityServices<Guid, int>();
services.AddSecurityServices<Guid, int, Guid>(tokenOptions);

return services;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class MappingProfiles : Profile
{
public MappingProfiles()
{
CreateMap<NArchitecture.Core.Security.Entities.RefreshToken<Guid>, RefreshToken>().ReverseMap();
CreateMap<NArchitecture.Core.Security.Entities.RefreshToken<Guid, Guid>, RefreshToken>().ReverseMap();
CreateMap<RefreshToken, RevokedTokenResponse>().ReverseMap();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ public async Task RefreshTokenShouldBeExists(RefreshToken? refreshToken)

public async Task RefreshTokenShouldBeActive(RefreshToken refreshToken)
{
if (refreshToken.RevokedDate != null && DateTime.UtcNow >= refreshToken.ExpiresDate)
if (refreshToken.RevokedDate != null && DateTime.UtcNow >= refreshToken.ExpirationDate)
await throwBusinessException(AuthMessages.InvalidRefreshToken);
}

public async Task UserEmailShouldBeNotExists(string email)
{
bool doesExists = await _userRepository.AnyAsync(predicate: u => u.Email == email, enableTracking: false);
bool doesExists = await _userRepository.AnyAsync(predicate: u => u.Email == email);
if (doesExists)
await throwBusinessException(AuthMessages.UserMailAlreadyExists);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ namespace Application.Services.AuthService;
public class AuthManager : IAuthService
{
private readonly IRefreshTokenRepository _refreshTokenRepository;
private readonly ITokenHelper<Guid, int> _tokenHelper;
private readonly ITokenHelper<Guid, int, Guid> _tokenHelper;
private readonly TokenOptions _tokenOptions;
private readonly IUserOperationClaimRepository _userOperationClaimRepository;
private readonly IMapper _mapper;

public AuthManager(
IUserOperationClaimRepository userOperationClaimRepository,
IRefreshTokenRepository refreshTokenRepository,
ITokenHelper<Guid, int> tokenHelper,
ITokenHelper<Guid, int, Guid> tokenHelper,
IConfiguration configuration,
IMapper mapper
)
Expand Down Expand Up @@ -81,7 +81,7 @@ public async Task RevokeRefreshToken(

public async Task<RefreshToken> RotateRefreshToken(User user, RefreshToken refreshToken, string ipAddress)
{
NArchitecture.Core.Security.Entities.RefreshToken<Guid> newCoreRefreshToken = _tokenHelper.CreateRefreshToken(
NArchitecture.Core.Security.Entities.RefreshToken<Guid, Guid> newCoreRefreshToken = _tokenHelper.CreateRefreshToken(
user,
ipAddress
);
Expand All @@ -96,15 +96,15 @@ public async Task RevokeDescendantRefreshTokens(RefreshToken refreshToken, strin
r.Token == refreshToken.ReplacedByToken
);

if (childToken?.RevokedDate != null && childToken.ExpiresDate <= DateTime.UtcNow)
if (childToken?.RevokedDate != null && childToken.ExpirationDate <= DateTime.UtcNow)
await RevokeRefreshToken(childToken, ipAddress, reason);
else
await RevokeDescendantRefreshTokens(refreshToken: childToken!, ipAddress, reason);
}

public Task<RefreshToken> CreateRefreshToken(User user, string ipAddress)
{
NArchitecture.Core.Security.Entities.RefreshToken<Guid> coreRefreshToken = _tokenHelper.CreateRefreshToken(
NArchitecture.Core.Security.Entities.RefreshToken<Guid, Guid> coreRefreshToken = _tokenHelper.CreateRefreshToken(
user,
ipAddress
);
Expand Down
4 changes: 2 additions & 2 deletions src/starterProject/Domain/Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Folder Include="Enums\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="NArchitecture.Core.Persistence" Version="1.0.0" />
<PackageReference Include="NArchitecture.Core.Security" Version="1.1.1" />
<PackageReference Include="NArchitecture.Core.Persistence" Version="1.1.1" />
<PackageReference Include="NArchitecture.Core.Security" Version="1.3.1" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/starterProject/Domain/Entities/RefreshToken.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Domain.Entities;

public class RefreshToken : NArchitecture.Core.Security.Entities.RefreshToken<Guid>
public class RefreshToken : NArchitecture.Core.Security.Entities.RefreshToken<Guid, Guid>
{
public virtual User User { get; set; } = default!;
}
2 changes: 1 addition & 1 deletion src/starterProject/Domain/Entities/UserOperationClaim.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Domain.Entities;

public class UserOperationClaim : NArchitecture.Core.Security.Entities.UserOperationClaim<Guid, int>
public class UserOperationClaim : NArchitecture.Core.Security.Entities.UserOperationClaim<Guid, Guid, int>
{
public virtual User User { get; set; } = default!;
public virtual OperationClaim OperationClaim { get; set; } = default!;
Expand Down
2 changes: 1 addition & 1 deletion src/starterProject/Infrastructure/Infrastructure.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CloudinaryDotNet" Version="1.25.1" />
<PackageReference Include="CloudinaryDotNet" Version="1.26.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Application\Application.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public void Configure(EntityTypeBuilder<RefreshToken> builder)
builder.Property(rt => rt.Id).HasColumnName("Id").IsRequired();
builder.Property(rt => rt.UserId).HasColumnName("UserId").IsRequired();
builder.Property(rt => rt.Token).HasColumnName("Token").IsRequired();
builder.Property(rt => rt.ExpiresDate).HasColumnName("ExpiresDate").IsRequired();
builder.Property(rt => rt.ExpirationDate).HasColumnName("ExpiresDate").IsRequired();
builder.Property(rt => rt.CreatedByIp).HasColumnName("CreatedByIp").IsRequired();
builder.Property(rt => rt.RevokedDate).HasColumnName("RevokedDate");
builder.Property(rt => rt.RevokedByIp).HasColumnName("RevokedByIp");
Expand Down
8 changes: 4 additions & 4 deletions src/starterProject/Persistence/Persistence.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
<ProjectReference Include="..\Application\Application.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.3" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageReference Include="NArchitecture.Core.Persistence" Version="1.0.0" />
<PackageReference Include="NArchitecture.Core.Persistence.DependencyInjection" Version="1.0.0" />
<PackageReference Include="NArchitecture.Core.Persistence" Version="1.1.1" />
<PackageReference Include="NArchitecture.Core.Persistence.DependencyInjection" Version="1.0.1" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public async Task<List<RefreshToken>> GetOldRefreshTokensAsync(Guid userId, int
.Where(r =>
r.UserId == userId
&& r.RevokedDate == null
&& r.ExpiresDate >= DateTime.UtcNow
&& r.ExpirationDate >= DateTime.UtcNow
&& r.CreatedDate.AddDays(refreshTokenTtl) <= DateTime.UtcNow
)
.ToListAsync();
Expand Down
2 changes: 1 addition & 1 deletion src/starterProject/WebAPI/Controllers/BaseController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected string getIpAddress()

protected Guid getUserIdFromRequest() //todo authentication behavior?
{
var userId = Guid.Parse(HttpContext.User.GetUserId().ToString()!);
var userId = Guid.Parse(HttpContext.User.GetIdClaim()!);
return userId;
}
}
4 changes: 3 additions & 1 deletion src/starterProject/WebAPI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
.Get<FileLogConfiguration>()
?? throw new InvalidOperationException("FileLogConfiguration section cannot found in configuration."),
elasticSearchConfig: builder.Configuration.GetSection("ElasticSearchConfig").Get<ElasticSearchConfig>()
?? throw new InvalidOperationException("ElasticSearchConfig section cannot found in configuration.")
?? throw new InvalidOperationException("ElasticSearchConfig section cannot found in configuration."),
tokenOptions: builder.Configuration.GetSection("TokenOptions").Get<TokenOptions>()
?? throw new InvalidOperationException("TokenOptions section cannot found in configuration.")
);
builder.Services.AddPersistenceServices(builder.Configuration);
builder.Services.AddInfrastructureServices();
Expand Down
8 changes: 4 additions & 4 deletions src/starterProject/WebAPI/WebAPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.3.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.2">
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.5.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="8.0.2" />
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="8.0.3" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="NArchitecture.Core.CrossCuttingConcerns.Exception.WebApi" Version="1.1.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ UserFakeData userFakeData
IUserRepository _userRepository = new MockUserRepository(userFakeData).GetUserMockRepository();
#endregion
#region Mock Helpers
ITokenHelper<Guid, int> tokenHelper = new JwtHelper<Guid, int>(_configuration);
TokenOptions tokenOptions =
_configuration.GetSection("TokenOptions").Get<TokenOptions>() ?? throw new Exception("Token options not found.");
ITokenHelper<Guid, int, Guid> tokenHelper = new JwtHelper<Guid, int, Guid>(tokenOptions);
IEmailAuthenticatorHelper emailAuthenticatorHelper = new EmailAuthenticatorHelper();
MailSettings mailSettings =
_configuration.GetSection("MailSettings").Get<MailSettings>() ?? throw new Exception("Mail settings not found.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="xunit" Version="2.6.6" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="NArchitecture.Core.Test" Version="1.0.0" />
<PackageReference Include="Xunit.DependencyInjection" Version="8.9.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<PackageReference Include="NArchitecture.Core.Test" Version="1.0.4" />
<PackageReference Include="Xunit.DependencyInjection" Version="9.0.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\starterProject\Application\Application.csproj" />
Expand Down

0 comments on commit a0cc8d5

Please sign in to comment.