Skip to content

Commit ae40f46

Browse files
Merge pull request #133 from Genocs/develop
Develop
2 parents 3c4e3fd + 3112bba commit ae40f46

File tree

179 files changed

+2574
-947
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

179 files changed

+2574
-947
lines changed

CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,34 @@ All notable changes to this project will be documented in this file. Dates are d
44

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

7+
#### [v7.2.0](https://github.com/Genocs/genocs-library/compare/v7.1.0...v7.2.0)
8+
9+
> 14 December 2024
10+
11+
- Update versions, remove Polly, and add configuration files [`bbb923f`](https://github.com/Genocs/genocs-library/commit/bbb923f2c15dc5bd99237d76a0114a2984f9d168)
12+
- Refactor and update codebase for C# 9.0 features [`74926b3`](https://github.com/Genocs/genocs-library/commit/74926b3edc638b9a7179ae6d3e746eec346cd0ab)
13+
- Add new service, project, and OpenTelemetry config [`42292cf`](https://github.com/Genocs/genocs-library/commit/42292cffc5b4b329377bf6adaf243504b3bc6073)
14+
- Refactor for multiple roles and sync methods [`db339c2`](https://github.com/Genocs/genocs-library/commit/db339c2ef27cd15cbbde0bfe9b1c9dac6e0a0c12)
15+
- Refactor authentication and JWT handling components [`5636ddc`](https://github.com/Genocs/genocs-library/commit/5636ddc9479d0a80a9c9c87c9175dc33f38d55bb)
16+
- Update configuration settings and service details [`1040881`](https://github.com/Genocs/genocs-library/commit/104088196666c31668f93a52fb89d6d2a70b7943)
17+
- Refactor namespaces and update OpenTelemetry config [`af280e0`](https://github.com/Genocs/genocs-library/commit/af280e0b6a7b08ab333f0ff2339aa068811f0f27)
18+
- Refactor and update configurations and dependencies [`2ba4d28`](https://github.com/Genocs/genocs-library/commit/2ba4d2829a4e635e2b52b0ea022716edd75c6f1c)
19+
- Add OpenTelemetry support and update various configurations [`0e6140b`](https://github.com/Genocs/genocs-library/commit/0e6140ba2ebb2bac7671e28e925546cca4611009)
20+
- Add CreateAdmin feature and refactor user creation [`dd2dfdf`](https://github.com/Genocs/genocs-library/commit/dd2dfdfe40cd45cc3ba02d7aaa04f7b8c1368f47)
21+
- Upgrade to .NET 9.0 and refine project configurations [`3fbbc7e`](https://github.com/Genocs/genocs-library/commit/3fbbc7e5597c7bb0b59383b39b0b4aedbf99bc8b)
22+
- Enhance JWT authentication and code organization [`5894fd7`](https://github.com/Genocs/genocs-library/commit/5894fd7232171ff202a9c2946b88602a149eec03)
23+
- Add JWT authentication and enhance authorization policies [`48b01f3`](https://github.com/Genocs/genocs-library/commit/48b01f31ac67b5bb9e60dcaf9d119031707bf23c)
24+
- Enhance logging, JWT options, and health checks [`86875f5`](https://github.com/Genocs/genocs-library/commit/86875f5d53e372be8a82f1bd2030aaacda6a7914)
25+
- Enable services and enhance configuration settings [`2654fe6`](https://github.com/Genocs/genocs-library/commit/2654fe6b756e97034960ba73c39b57429678295f)
26+
- Refactor JWT handling and improve code readability [`b525d35`](https://github.com/Genocs/genocs-library/commit/b525d35a18add383b0960d4405069b91a97decd5)
27+
- Refactor and improve nullability handling [`07bee95`](https://github.com/Genocs/genocs-library/commit/07bee95f1226ab4406078380da2b25744f413d8e)
28+
- Add console exporter support for OpenTelemetry [`5f0ca21`](https://github.com/Genocs/genocs-library/commit/5f0ca21d0f36032c62102833ea95ad63c1b809aa)
29+
- Update error handling, tracing, and configuration [`eda7085`](https://github.com/Genocs/genocs-library/commit/eda7085847b057983269dd6fd08c237644dfe553)
30+
- Enhance GenocsBuilder and update Program.cs structure [`23aa7c6`](https://github.com/Genocs/genocs-library/commit/23aa7c6418365f49be9de771be028dae7758c02a)
31+
- Standardize property names and improve documentation [`8e48cfa`](https://github.com/Genocs/genocs-library/commit/8e48cfa891777398b276965dd3f02d3b536e75ad)
32+
- Add OtlpEndpoint to LoggerOptions and update exception handling [`3df7280`](https://github.com/Genocs/genocs-library/commit/3df72803f83a03922523c036cfe2686cd9c0bfec)
33+
- Update package versions and modify exception logic [`f24c465`](https://github.com/Genocs/genocs-library/commit/f24c46508d67da55fab3cc96c3ebb295977e9222)
34+
735
#### [v7.1.0](https://github.com/Genocs/genocs-library/compare/v7.0.0...v7.1.0)
836

937
> 29 November 2024

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)dotnet.ruleset</CodeAnalysisRuleSet>
1414
<GenerateDocumentationFile>True</GenerateDocumentationFile>
1515
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
16-
<Version>6.3.0</Version>
16+
<Version>7.1.0</Version>
1717
<LangVersion>13.0</LangVersion>
1818
<Company>Genocs</Company>
1919
<Copyright>Genocs 2024</Copyright>

containers/infrastructure-monitoring.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11
services:
2+
aspire:
3+
image: mcr.microsoft.com/dotnet/aspire-dashboard:9.0
4+
hostname: aspire_dashboard
5+
container_name: aspire_dashboard
6+
ports:
7+
- 18888:18888
8+
- 4318:18889
9+
10+
environment:
11+
- DOTNET_DASHBOARD_UNSECURED_ALLOW_ANONYMOUS=true
12+
13+
networks:
14+
- genocs
15+
# network_mode: host
16+
217
grafana:
318
image: grafana/grafana
419
hostname: grafana

genocs.sln

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,18 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Application", "Application"
123123
src\apps\docker-compose.override.yml = src\apps\docker-compose.override.yml
124124
src\apps\docker-compose.yml = src\apps\docker-compose.yml
125125
src\apps\identity-webapi.dockerfile = src\apps\identity-webapi.dockerfile
126-
src\apps\order-webapi.dockerfile = src\apps\order-webapi.dockerfile
127126
src\apps\local.env = src\apps\local.env
127+
src\apps\order-webapi.dockerfile = src\apps\order-webapi.dockerfile
128128
src\apps\product-webapi.dockerfile = src\apps\product-webapi.dockerfile
129129
src\apps\signalr-webapi.dockerfile = src\apps\signalr-webapi.dockerfile
130130
EndProjectSection
131131
EndProject
132132
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Genocs.Secrets.AzureKeyVault", "src\Genocs.Secrets.AzureKeyVault\Genocs.Secrets.AzureKeyVault.csproj", "{ECBF1AEE-AE3A-4F81-9943-5675169DEFA7}"
133133
EndProject
134+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Genocs.OpenTelemetry", "src\Genocs.OpenTelemetry\Genocs.OpenTelemetry.csproj", "{62380657-23D0-0ECD-8FFE-0B1DA5461D37}"
135+
EndProject
136+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Genocs.Core.Demo.HelloWorld", "src\Genocs.Core.Demo.HelloWorld\Genocs.Core.Demo.HelloWorld.csproj", "{D7C394CF-487D-470D-B05C-CC2DD7EC290B}"
137+
EndProject
134138
Global
135139
GlobalSection(SolutionConfigurationPlatforms) = preSolution
136140
Debug|Any CPU = Debug|Any CPU
@@ -297,6 +301,14 @@ Global
297301
{ECBF1AEE-AE3A-4F81-9943-5675169DEFA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
298302
{ECBF1AEE-AE3A-4F81-9943-5675169DEFA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
299303
{ECBF1AEE-AE3A-4F81-9943-5675169DEFA7}.Release|Any CPU.Build.0 = Release|Any CPU
304+
{62380657-23D0-0ECD-8FFE-0B1DA5461D37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
305+
{62380657-23D0-0ECD-8FFE-0B1DA5461D37}.Debug|Any CPU.Build.0 = Debug|Any CPU
306+
{62380657-23D0-0ECD-8FFE-0B1DA5461D37}.Release|Any CPU.ActiveCfg = Release|Any CPU
307+
{62380657-23D0-0ECD-8FFE-0B1DA5461D37}.Release|Any CPU.Build.0 = Release|Any CPU
308+
{D7C394CF-487D-470D-B05C-CC2DD7EC290B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
309+
{D7C394CF-487D-470D-B05C-CC2DD7EC290B}.Debug|Any CPU.Build.0 = Debug|Any CPU
310+
{D7C394CF-487D-470D-B05C-CC2DD7EC290B}.Release|Any CPU.ActiveCfg = Release|Any CPU
311+
{D7C394CF-487D-470D-B05C-CC2DD7EC290B}.Release|Any CPU.Build.0 = Release|Any CPU
300312
EndGlobalSection
301313
GlobalSection(SolutionProperties) = preSolution
302314
HideSolutionNode = FALSE
@@ -325,6 +337,7 @@ Global
325337
{B2028A73-6C94-4166-A0BB-22080805E351} = {140B7191-88E9-4EEE-9D86-9A70839F8507}
326338
{6CE8740F-8561-481B-AC9F-D1E73C449235} = {B2028A73-6C94-4166-A0BB-22080805E351}
327339
{B184733D-2415-4517-BC65-26ED22EEB2C2} = {51A2E158-4686-4764-91D5-3CDDD06280D4}
340+
{D7C394CF-487D-470D-B05C-CC2DD7EC290B} = {220036E9-322D-4D4A-BA98-21DCF111C50A}
328341
EndGlobalSection
329342
GlobalSection(ExtensibilityGlobals) = postSolution
330343
SolutionGuid = {FF634A51-3CA4-4FB3-A8ED-71C403516166}

global.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"sdk": {
3-
"version": "8.0.10",
3+
"version": "9.0.0",
44
"rollForward": "latestMajor",
55
"allowPrerelease": true
66
}
7-
}
7+
}

launchSettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
}
99
}
1010
}
11-
}
11+
}

src/Genocs.Auth/AccessTokenValidatorMiddleware.cs

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,36 @@ namespace Genocs.Auth;
77
/// <summary>
88
/// The access token validator middleware.
99
/// </summary>
10-
public class AccessTokenValidatorMiddleware : IMiddleware
10+
/// <remarks>
11+
/// The AccessTokenValidatorMiddleware constructor.
12+
/// </remarks>
13+
/// <param name="accessTokenService">The access token service.</param>
14+
/// <param name="options">The options.</param>
15+
public class AccessTokenValidatorMiddleware(IAccessTokenService accessTokenService, JwtOptions options) : IMiddleware
1116
{
12-
private readonly IAccessTokenService _accessTokenService;
13-
private readonly IEnumerable<string> _endpoints;
14-
15-
/// <summary>
16-
/// The AccessTokenValidatorMiddleware constructor.
17-
/// </summary>
18-
/// <param name="accessTokenService">The access token service.</param>
19-
/// <param name="options">The options.</param>
20-
public AccessTokenValidatorMiddleware(IAccessTokenService accessTokenService, JwtOptions options)
21-
{
22-
_accessTokenService = accessTokenService;
23-
_endpoints = options.AllowAnonymousEndpoints ?? Enumerable.Empty<string>();
24-
}
17+
private readonly IAccessTokenService _accessTokenService = accessTokenService;
18+
private readonly IEnumerable<string> _allowAnonymousEndpoints = options.AllowAnonymousEndpoints ?? [];
2519

2620
/// <summary>
2721
/// The InvokeAsync method.
2822
/// </summary>
2923
/// <param name="context">The http context.</param>
3024
/// <param name="next">The request delegate.</param>
31-
/// <returns></returns>
25+
/// <returns>The task.</returns>
3226
public async Task InvokeAsync(HttpContext context, RequestDelegate next)
3327
{
3428
string path = context.Request.Path.HasValue ? context.Request.Path.Value : string.Empty;
3529

36-
if (_endpoints.Contains(path))
30+
// Skip check on AnonymousEndpoints
31+
if (_allowAnonymousEndpoints.Contains(path))
3732
{
3833
await next(context);
39-
4034
return;
4135
}
4236

43-
if (await _accessTokenService.IsCurrentActiveToken())
37+
if (_accessTokenService.IsCurrentActiveToken())
4438
{
4539
await next(context);
46-
4740
return;
4841
}
4942

src/Genocs.Auth/Configurations/JwtOptions.cs

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using Microsoft.IdentityModel.Tokens;
2+
13
namespace Genocs.Auth.Configurations;
24

35
public class JwtOptions
@@ -14,7 +16,12 @@ public class JwtOptions
1416

1517
public IEnumerable<string>? AllowAnonymousEndpoints { get; set; }
1618
public CertificateOptions? Certificate { get; set; }
17-
public string? Algorithm { get; set; }
19+
20+
/// <summary>
21+
/// The algorithm used to sign the token.
22+
/// Defaults to SecurityAlgorithms.HmacSha256 'HS256'.
23+
/// </summary>
24+
public string Algorithm { get; set; } = SecurityAlgorithms.HmacSha256;
1825
public string? Issuer { get; set; }
1926
public string? IssuerSigningKey { get; set; }
2027
public string? Authority { get; set; }
@@ -31,7 +38,12 @@ public class JwtOptions
3138
public bool RequireHttpsMetadata { get; set; }
3239
public bool RequireExpirationTime { get; set; } = true;
3340
public bool RequireSignedTokens { get; set; } = true;
34-
public int ExpiryMinutes { get; set; }
41+
42+
/// <summary>
43+
/// The expiration time of the token in minutes.
44+
/// Defaults to 60 minutes.
45+
/// </summary>
46+
public int ExpiryMinutes { get; set; } = 60;
3547
public TimeSpan? Expiry { get; set; }
3648
public string? ValidAudience { get; set; }
3749
public IEnumerable<string>? ValidAudiences { get; set; }
@@ -65,19 +77,31 @@ public class JwtOptions
6577
/// Defaults to true.
6678
/// </summary>
6779
public bool IncludeErrorDetails { get; set; } = true;
80+
6881
public string? AuthenticationType { get; set; }
6982
public string? NameClaimType { get; set; }
7083

7184
/// <summary>
7285
/// The claim type that will be used to determine the user's roles.
73-
/// Defaults to "Role".
86+
/// Default is "Role".
7487
/// </summary>
7588
public string RoleClaimType { get; set; } = "Role";
7689

7790
public class CertificateOptions
7891
{
92+
/// <summary>
93+
/// The location of the certificate.
94+
/// </summary>
7995
public string? Location { get; set; }
96+
97+
/// <summary>
98+
/// The certificate as a byte array.
99+
/// </summary>
80100
public string? RawData { get; set; }
101+
102+
/// <summary>
103+
/// The certificate password.
104+
/// </summary>
81105
public string? Password { get; set; }
82106
}
83107
}

src/Genocs.Auth/DisabledAuthenticationPolicyEvaluator.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ internal sealed class DisabledAuthenticationPolicyEvaluator : IPolicyEvaluator
1717
/// <returns></returns>
1818
public Task<AuthenticateResult> AuthenticateAsync(AuthorizationPolicy policy, HttpContext context)
1919
{
20-
var authenticationTicket = new AuthenticationTicket(
21-
new ClaimsPrincipal(),
22-
new AuthenticationProperties(),
23-
JwtBearerDefaults.AuthenticationScheme);
20+
var authenticationTicket = new AuthenticationTicket(new ClaimsPrincipal(), new AuthenticationProperties(), JwtBearerDefaults.AuthenticationScheme);
2421

2522
return Task.FromResult(AuthenticateResult.Success(authenticationTicket));
2623
}
@@ -33,11 +30,7 @@ public Task<AuthenticateResult> AuthenticateAsync(AuthorizationPolicy policy, Ht
3330
/// <param name="context"></param>
3431
/// <param name="resource"></param>
3532
/// <returns></returns>
36-
public Task<PolicyAuthorizationResult> AuthorizeAsync(
37-
AuthorizationPolicy policy,
38-
AuthenticateResult authenticationResult,
39-
HttpContext context,
40-
object resource)
33+
public Task<PolicyAuthorizationResult> AuthorizeAsync(AuthorizationPolicy policy, AuthenticateResult authenticationResult, HttpContext context, object resource)
4134
{
4235
return Task.FromResult(PolicyAuthorizationResult.Success());
4336
}

0 commit comments

Comments
 (0)