Skip to content

Commit 7661260

Browse files
committed
Added comments
1 parent a3170e5 commit 7661260

File tree

27 files changed

+305
-71
lines changed

27 files changed

+305
-71
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
---
12-
This repo contains a set of libraries designed by Genocs. The libraries are built using .NET standard 2.1 or .NET7.
12+
This repo contains a set of libraries designed by Genocs. The libraries are built using .NET standard 2.1, .NET6 and .NET7.
1313

1414
Packages are available on [NuGet Genocs](https://www.nuget.org/profiles/gioema_nocco).
1515

src/Genocs.Auth/AccessTokenValidatorMiddleware.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,32 @@
33

44
namespace Genocs.Auth;
55

6+
7+
/// <summary>
8+
/// The access token validator middleware
9+
/// </summary>
610
public class AccessTokenValidatorMiddleware : IMiddleware
711
{
812
private readonly IAccessTokenService _accessTokenService;
913
private readonly IEnumerable<string> _endpoints;
1014

15+
/// <summary>
16+
/// The AccessTokenValidatorMiddleware constructor
17+
/// </summary>
18+
/// <param name="accessTokenService">The access token service</param>
19+
/// <param name="options">The options</param>
1120
public AccessTokenValidatorMiddleware(IAccessTokenService accessTokenService, JwtOptions options)
1221
{
1322
_accessTokenService = accessTokenService;
1423
_endpoints = options.AllowAnonymousEndpoints ?? Enumerable.Empty<string>();
1524
}
1625

26+
/// <summary>
27+
/// The InvokeAsync method
28+
/// </summary>
29+
/// <param name="context">The http context</param>
30+
/// <param name="next">The request delegate</param>
31+
/// <returns></returns>
1732
public async Task InvokeAsync(HttpContext context, RequestDelegate next)
1833
{
1934
var path = context.Request.Path.HasValue ? context.Request.Path.Value : string.Empty;

src/Genocs.Auth/AuthAttribute.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ public class AuthAttribute : AuthorizeAttribute
1010
/// <summary>
1111
/// The AuthAttribute constructor
1212
/// </summary>
13-
/// <param name="scheme"></param>
14-
/// <param name="policy"></param>
13+
/// <param name="scheme">The authorization schema</param>
14+
/// <param name="policy">The authorization policy</param>
1515
public AuthAttribute(string scheme, string policy = "") : base(policy)
1616
{
1717
AuthenticationSchemes = scheme;

src/Genocs.Auth/DisabledAuthenticationPolicyEvaluator.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,27 @@ namespace Genocs.Auth;
99

1010
internal sealed class DisabledAuthenticationPolicyEvaluator : IPolicyEvaluator
1111
{
12+
/// <summary>
13+
///
14+
/// </summary>
15+
/// <param name="policy"></param>
16+
/// <param name="context"></param>
17+
/// <returns></returns>
1218
public Task<AuthenticateResult> AuthenticateAsync(AuthorizationPolicy policy, HttpContext context)
1319
{
1420
var authenticationTicket = new AuthenticationTicket(new ClaimsPrincipal(),
1521
new AuthenticationProperties(), JwtBearerDefaults.AuthenticationScheme);
1622
return Task.FromResult(AuthenticateResult.Success(authenticationTicket));
1723
}
1824

25+
/// <summary>
26+
///
27+
/// </summary>
28+
/// <param name="policy"></param>
29+
/// <param name="authenticationResult"></param>
30+
/// <param name="context"></param>
31+
/// <param name="resource"></param>
32+
/// <returns></returns>
1933
public Task<PolicyAuthorizationResult> AuthorizeAsync(AuthorizationPolicy policy,
2034
AuthenticateResult authenticationResult, HttpContext context, object resource)
2135
{

src/Genocs.Auth/Handlers/JwtHandler.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ public JsonWebToken CreateToken(string userId,
107107
};
108108
}
109109

110+
/// <summary>
111+
/// Gets the token payload.
112+
/// </summary>
113+
/// <param name="accessToken"></param>
114+
/// <returns></returns>
110115
public JsonWebTokenPayload? GetTokenPayload(string accessToken)
111116
{
112117
_jwtSecurityTokenHandler.ValidateToken(accessToken, _tokenValidationParameters,

src/Genocs.Auth/IJwtHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ JsonWebToken CreateToken(string userId,
2323
/// </summary>
2424
/// <param name="accessToken">The access token string value</param>
2525
/// <returns>The JsonWebTokenPayload</returns>
26-
JsonWebTokenPayload GetTokenPayload(string accessToken);
26+
JsonWebTokenPayload? GetTokenPayload(string accessToken);
2727
}

src/Genocs.Auth/JsonWebToken.cs

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,38 @@
11
namespace Genocs.Auth;
22

3+
4+
/// <summary>
5+
/// The JSON Web Token definition.
6+
/// </summary>
37
public class JsonWebToken
48
{
5-
public string AccessToken { get; set; }
6-
public string RefreshToken { get; set; }
9+
/// <summary>
10+
/// Gets or sets the access token.
11+
/// </summary>
12+
public string? AccessToken { get; set; }
13+
14+
/// <summary>
15+
/// Gets or sets the refresh token.
16+
/// </summary>
17+
public string? RefreshToken { get; set; }
18+
19+
/// <summary>
20+
/// Gets or sets the access token expiration.
21+
/// </summary>
722
public long Expires { get; set; }
8-
public string Id { get; set; }
9-
public string Role { get; set; }
10-
public IDictionary<string, IEnumerable<string>> Claims { get; set; }
23+
24+
/// <summary>
25+
/// Gets or sets the access token unique identifier.
26+
/// </summary>
27+
public string? Id { get; set; }
28+
29+
/// <summary>
30+
/// Gets or sets the access token role.
31+
/// </summary>
32+
public string? Role { get; set; }
33+
34+
/// <summary>
35+
/// The claims.
36+
/// </summary>
37+
public IDictionary<string, IEnumerable<string>>? Claims { get; set; }
1138
}

src/Genocs.Auth/Services/InMemoryAccessTokenService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ private string GetCurrentAsync()
4545

4646
if (authorizationHeader is null)
4747
{
48-
return StringValues.Empty;
48+
return string.Empty;
4949
}
5050

5151
return authorizationHeader.Value == StringValues.Empty

src/Genocs.Core.Demo.Worker/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
services
4040
.AddGenocs(hostContext.Configuration)
41-
.AddMongoFast() // It adds the MongoDb Repository to the project and register all the Domain Objects with the standard interface
41+
.AddMongoFast()
4242
.RegisterMongoRepositories(Assembly.GetExecutingAssembly()); // It registers the repositories that has been overridden. No need in case of standard repository
4343

4444
ConfigureMassTransit(services, hostContext.Configuration);

src/Genocs.Core/CQRS/Queries/PagedResult.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ protected PagedResult()
3333
/// <param name="totalResults"></param>
3434
[JsonConstructor]
3535
protected PagedResult(IEnumerable<T> items,
36-
int currentPage, int resultsPerPage,
37-
int totalPages, long totalResults) :
36+
int currentPage,
37+
int resultsPerPage,
38+
int totalPages,
39+
long totalResults) :
3840
base(currentPage, resultsPerPage, totalPages, totalResults)
3941
{
4042
Items = items;

0 commit comments

Comments
 (0)