Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v6.3.0](https://github.com/Genocs/genocs-library/compare/v6.2.0...v6.3.0)

> 3 November 2024

- Update project files and package references [`34415fa`](https://github.com/Genocs/genocs-library/commit/34415fa90e252c2654ddeebf5a8f84789d29be20)
- Update Genocs packages from 6.2.0 to 6.3.0 [`950efdb`](https://github.com/Genocs/genocs-library/commit/950efdb79522da4661f8fba43d020d07e4a6d927)
- Update package versions to 6.2.0 in multiple projects [`328f67e`](https://github.com/Genocs/genocs-library/commit/328f67e3a0f1ceb1be16be1d7eff0c679c5e5a8e)
- Update project references and improve domain entities [`24589b4`](https://github.com/Genocs/genocs-library/commit/24589b4a5cc52bb99609c3089b2e366343f5688e)
- Update Roslynator.Analyzers and adjust framework references [`6e9af26`](https://github.com/Genocs/genocs-library/commit/6e9af26c48bad5298f20430eca65f06b0a2c99f4)
- Update to 6.2.0, replace Jaeger with OpenTelemetry [`ee78547`](https://github.com/Genocs/genocs-library/commit/ee785472f89c00bb5e53ad066b9d7b8b2588fffa)
- Update packages, enhance JWT options, and refactor configs [`ded3efb`](https://github.com/Genocs/genocs-library/commit/ded3efb09cdb4b9b42b5d36102cf45bea608e84c)

#### [v6.2.0](https://github.com/Genocs/genocs-library/compare/v6.1.0...v6.2.0)

> 22 October 2024
Expand Down
18 changes: 17 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)dotnet.ruleset</CodeAnalysisRuleSet>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<Version>6.3.0</Version>
<LangVersion>10.0</LangVersion>
<Company>Genocs</Company>
<Copyright>Genocs 2024</Copyright>
Expand All @@ -21,7 +22,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Roslynator.Analyzers" Version="4.12.8">
<PackageReference Include="Roslynator.Analyzers" Version="4.12.9">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand All @@ -35,6 +36,21 @@
<AdditionalFiles Include="$(MSBuildThisFileDirectory).editorconfig" Link="Properties\.editorconfig" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\LICENSE">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<None Include="..\..\icon.png">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<None Include="README_NUGET.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

<!--
This Directory.Build.props files sets default properties that apply to all projects found in
this folder or subfolders, recursively.
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "7.0.0",
"version": "8.0.10",
"rollForward": "latestMajor",
"allowPrerelease": true
}
Expand Down
31 changes: 28 additions & 3 deletions src/Genocs.Auth/Configurations/JwtOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,41 @@ public class JwtOptions
public string? ValidIssuer { get; set; }
public IEnumerable<string>? ValidIssuers { get; set; }
public bool ValidateActor { get; set; }
public bool ValidateAudience { get; set; }
public bool ValidateIssuer { get; set; }

/// <summary>
/// It defines whether the audience should be validated.
/// Defaults to true.
/// </summary>
public bool ValidateAudience { get; set; } = true;

/// <summary>
/// It defines whether the issuer should be validated.
/// Defaults to true.
/// </summary>
public bool ValidateIssuer { get; set; } = true;
public bool ValidateLifetime { get; set; } = true;
public bool ValidateTokenReplay { get; set; }
public bool ValidateIssuerSigningKey { get; set; }

/// <summary>
/// It defines whether the token should be refreshed when the issuer key is not found.
/// Defaults to true.
/// </summary>
public bool RefreshOnIssuerKeyNotFound { get; set; } = true;

/// <summary>
/// It defines whether the error details should be included in the response.
/// Defaults to true.
/// </summary>
public bool IncludeErrorDetails { get; set; } = true;
public string? AuthenticationType { get; set; }
public string? NameClaimType { get; set; }
public string? RoleClaimType { get; set; }

/// <summary>
/// The claim type that will be used to determine the user's roles.
/// Defaults to "Role".
/// </summary>
public string RoleClaimType { get; set; } = "Role";

public class CertificateOptions
{
Expand Down
2 changes: 2 additions & 0 deletions src/Genocs.Auth/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ private static IGenocsBuilder AddJwt(
SaveSigninToken = options.SaveSigninToken,
RequireExpirationTime = options.RequireExpirationTime,
RequireSignedTokens = options.RequireSignedTokens,
RoleClaimType = options.RoleClaimType,
ClockSkew = TimeSpan.Zero
};

Expand Down Expand Up @@ -117,6 +118,7 @@ private static IGenocsBuilder AddJwt(
}
}

// If no certificate is provided, use symmetric encryption.
if (!string.IsNullOrWhiteSpace(options.IssuerSigningKey) && !hasCertificate)
{
if (string.IsNullOrWhiteSpace(options.Algorithm) || hasCertificate)
Expand Down
20 changes: 2 additions & 18 deletions src/Genocs.Auth/Genocs.Auth.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<Title>The authorization library useful to build .NET Core projects.</Title>
<Description>The authorization library useful to build .NET Core projects.</Description>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>6.2.0</Version>
<MinClientVersion>5.0.0</MinClientVersion>
<Authors>Nocco Giovanni Emanuele</Authors>
<PackageTags>microservice microservices solid solid-principles authentication genocs</PackageTags>
Expand All @@ -18,30 +17,15 @@
<AnalysisLevel>latest</AnalysisLevel>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\LICENSE">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<None Include="..\..\icon.png">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<None Include="README_NUGET.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

<ItemGroup Condition="'$(Configuration)' == 'Debug'">
<ProjectReference Include="..\Genocs.Core\Genocs.Core.csproj" />
<ProjectReference Include="..\Genocs.Security\Genocs.Security.csproj" />

</ItemGroup>

<ItemGroup Condition="'$(Configuration)' == 'Release'">
<PackageReference Include="Genocs.Core" Version="6.2.0" />
<PackageReference Include="Genocs.Security" Version="6.2.0" />
<PackageReference Include="Genocs.Core" Version="6.3.0" />
<PackageReference Include="Genocs.Security" Version="6.3.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
Expand Down
20 changes: 2 additions & 18 deletions src/Genocs.Common/Genocs.Common.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net7.0;net6.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
<PackageId>Genocs.Common</PackageId>
<RootNamespace>Genocs.Common</RootNamespace>
<AssemblyName>Genocs.Common</AssemblyName>
<Title>The Genocs Library - Common components.</Title>
<Description>The common components to build .NET Core projects along with Genocs Library.</Description>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>6.2.0</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<MinClientVersion>5.0.0</MinClientVersion>
<Authors>Nocco Giovanni Emanuele</Authors>
<PackageTags>microservice microservices solid solid-principles genocs</PackageTags>
Expand All @@ -18,19 +17,4 @@
<AnalysisLevel>latest</AnalysisLevel>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\LICENSE">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<None Include="..\..\icon.png">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<None Include="README_NUGET.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</ItemGroup>

<ItemGroup Condition="'$(Configuration)' == 'Release'">
<PackageReference Include="Genocs.Core" Version="6.2.0" />
<PackageReference Include="Genocs.Core" Version="6.3.0" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions src/Genocs.Core.Demo.Domain/Genocs.Core.Demo.Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
</ItemGroup>

<ItemGroup Condition="'$(Configuration)' == 'Release'">
<PackageReference Include="Genocs.Persistence.MongoDb" Version="6.2.0" />
<PackageReference Include="Genocs.Core" Version="6.2.0" />
<PackageReference Include="Genocs.Persistence.MongoDb" Version="6.3.0" />
<PackageReference Include="Genocs.Core" Version="6.3.0" />
</ItemGroup>

</Project>
25 changes: 13 additions & 12 deletions src/Genocs.Core.Demo.WebApi/Genocs.Core.Demo.WebApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,37 @@

<ItemGroup Condition="'$(Configuration)' == 'Debug'">
<ProjectReference Include="..\Genocs.ServiceBusAzure\Genocs.ServiceBusAzure.csproj" />
<ProjectReference Include="..\Genocs.Core\Genocs.Core.csproj" />
<ProjectReference Include="..\Genocs.Auth\Genocs.Auth.csproj" />
<ProjectReference Include="..\Genocs.Logging\Genocs.Logging.csproj" />
<ProjectReference Include="..\Genocs.Tracing\Genocs.Tracing.csproj" />
<ProjectReference Include="..\Genocs.HTTP\Genocs.HTTP.csproj" />
<ProjectReference Include="..\Genocs.Security\Genocs.Security.csproj" />
<ProjectReference Include="..\Genocs.WebApi\Genocs.WebApi.csproj" />
<ProjectReference Include="..\Genocs.WebApi.Security\Genocs.WebApi.Security.csproj" />
<ProjectReference Include="..\Genocs.Secrets.AzureKeyVault\Genocs.Secrets.AzureKeyVault.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(Configuration)' == 'Release'">
<PackageReference Include="Genocs.ServiceBusAzure" Version="6.2.0" />
<PackageReference Include="Genocs.Core" Version="6.2.0" />
<PackageReference Include="Genocs.Auth" Version="6.2.0" />
<PackageReference Include="Genocs.Logging" Version="6.2.0" />
<PackageReference Include="Genocs.Tracing" Version="6.2.0" />
<PackageReference Include="Genocs.HTTP" Version="6.2.0" />
<PackageReference Include="Genocs.Security" Version="6.2.0" />
<PackageReference Include="Genocs.WebApi.Security" Version="6.2.0" />
<PackageReference Include="Genocs.ServiceBusAzure" Version="6.3.0" />
<PackageReference Include="Genocs.Auth" Version="6.3.0" />
<PackageReference Include="Genocs.Logging" Version="6.3.0" />
<PackageReference Include="Genocs.Tracing" Version="6.3.0" />
<PackageReference Include="Genocs.HTTP" Version="6.3.0" />
<PackageReference Include="Genocs.Security" Version="6.3.0" />
<PackageReference Include="Genocs.WebApi" Version="6.3.0" />
<PackageReference Include="Genocs.WebApi.Security" Version="6.3.0" />
<PackageReference Include="Genocs.Secrets.AzureKeyVault" Version="6.3.0" />

</ItemGroup>

<ItemGroup>
<PackageReference Include="MassTransit.RabbitMQ" Version="8.2.5" />
<PackageReference Include="MassTransit.RabbitMQ" Version="8.3.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.8.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Genocs.Core.Demo.Contracts\Genocs.Core.Demo.Contracts.csproj" />
<ProjectReference Include="..\Genocs.Core.Demo.Domain\Genocs.Core.Demo.Domain.csproj" />
<ProjectReference Include="..\Genocs.Secrets.AzureKeyVault\Genocs.Secrets.AzureKeyVault.csproj" />
<ProjectReference Include="..\Genocs.WebApi\Genocs.WebApi.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,16 @@ public static IServiceCollection AddCustomMassTransit(this IServiceCollection se
x.UsingRabbitMq((context, cfg) =>
{
cfg.ConfigureEndpoints(context);
//cfg.UseHealthCheck(context);
cfg.Host(rabbitMQSettings.HostName, rabbitMQSettings.VirtualHost,
h =>
{
h.Username(rabbitMQSettings.UserName);
h.Password(rabbitMQSettings.Password);
}
);

// cfg.UseHealthCheck(context);
cfg.Host(
rabbitMQSettings.HostName,
rabbitMQSettings.VirtualHost,
h =>
{
h.Username(rabbitMQSettings.UserName);
h.Password(rabbitMQSettings.Password);
});
});
});

Expand Down
2 changes: 2 additions & 0 deletions src/Genocs.Core.Demo.WebApi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Genocs.Tracing;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Serilog;
using Genocs.Auth;
using System.Reflection;
using System.Text.Json.Serialization;

Expand All @@ -23,6 +24,7 @@

services
.AddGenocs(builder.Configuration)
.AddJwt()
// .AddOpenIdJwt()
.AddOpenTelemetry()
.AddMongoFast()
Expand Down
12 changes: 11 additions & 1 deletion src/Genocs.Core.Demo.WebApi/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@
"ValidAudience": "https://localhost:5000",
"Secret": ""
},
"_simmetric_jwt": {
"issuerSigningKey": "This is my custom Secret key for authentication S0M3RAN0MS3CR3T!1!MAG1C!1!",
"requireHttpsMetadata": false,
"saveToken": true,
"validateIssuerSigningKey": true,
"validateIssuer": false,
"validateLifetime": true,
"validateAudience": false,
"roleClaimType": "Role"
},
"rabbitMQ": {
"HostName": "localhost",
"VirtualHost": "/",
Expand All @@ -53,7 +63,7 @@
"enableTracing": true
},
"azureKeyVault": {
"enabled": true,
"enabled": false,
"name": "kv-genocs"
},
"secrets": {
Expand Down
8 changes: 4 additions & 4 deletions src/Genocs.Core.Demo.Worker/Genocs.Core.Demo.Worker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
</ItemGroup>

<ItemGroup Condition="'$(Configuration)' == 'Release'">
<PackageReference Include="Genocs.ServiceBusAzure" Version="6.2.0" />
<PackageReference Include="Genocs.Logging" Version="6.2.0" />
<PackageReference Include="Genocs.Tracing" Version="6.2.0" />
<PackageReference Include="Genocs.ServiceBusAzure" Version="6.3.0" />
<PackageReference Include="Genocs.Logging" Version="6.3.0" />
<PackageReference Include="Genocs.Tracing" Version="6.3.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="MassTransit.Extensions.DependencyInjection" Version="7.3.1" />
<PackageReference Include="MassTransit.RabbitMQ" Version="8.2.5" />
<PackageReference Include="MassTransit.RabbitMQ" Version="8.3.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
<PackageReference Include="Serilog.Sinks.ApplicationInsights" Version="4.0.0" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Genocs.Core/Domain/Entities/AggregateRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Genocs.Core.Domain.Entities;

public class AggregateRoot : AggregateRoot<int>, IAggregateRoot
public class AggregateRoot : AggregateRoot<Guid>, IAggregateRoot
{

}
Expand Down
4 changes: 2 additions & 2 deletions src/Genocs.Core/Domain/Entities/Auditing/AuditedEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace Genocs.Core.Domain.Entities.Auditing;

/// <summary>
/// A shortcut of <see cref="AuditedEntity{TPrimaryKey}"/> for most used primary key type (<see cref="int"/>).
/// A shortcut of <see cref="AuditedEntity{TPrimaryKey}"/> for most used primary key type (<see cref="Guid"/>).
/// </summary>
[Serializable]
public abstract class AuditedEntity : AuditedEntity<int>, IEntity
public abstract class AuditedEntity : AuditedEntity<Guid>, IEntity
{

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
namespace Genocs.Core.Domain.Entities.Auditing;

/// <summary>
/// A shortcut of <see cref="CreationAuditedEntity{TPrimaryKey}"/> for most used primary key type (<see cref="int"/>).
/// A shortcut of <see cref="CreationAuditedEntity{TPrimaryKey}"/> for most used primary key type (<see cref="Guid"/>).
/// </summary>
[Serializable]
public abstract class CreationAuditedEntity : CreationAuditedEntity<int>, IEntity
public abstract class CreationAuditedEntity : CreationAuditedEntity<Guid>, IEntity
{

}
Expand Down
Loading