Skip to content

Commit

Permalink
update project
Browse files Browse the repository at this point in the history
  • Loading branch information
sventhiel committed Sep 16, 2023
1 parent 73040c9 commit 1230626
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 20 deletions.
8 changes: 4 additions & 4 deletions Authentication/BasicAuthenticationHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public BasicAuthenticationHandler(
_admins = configuration.GetSection("Admins").Get<List<Admin>>();
}

protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
protected override Task<AuthenticateResult> HandleAuthenticateAsync()
{
var authHeader = Request.Headers["Authorization"].ToString();
if (authHeader != null && authHeader.StartsWith("basic", StringComparison.OrdinalIgnoreCase))
Expand All @@ -54,18 +54,18 @@ protected override async Task<AuthenticateResult> HandleAuthenticateAsync()

var identity = new ClaimsIdentity(claims, "Basic");
var claimsPrincipal = new ClaimsPrincipal(identity);
return AuthenticateResult.Success(new AuthenticationTicket(claimsPrincipal, Scheme.Name));
return Task.FromResult(AuthenticateResult.Success(new AuthenticationTicket(claimsPrincipal, Scheme.Name)));
}

Response.StatusCode = 401;
Response.Headers.Add("www-authenticate", "Basic Authorization");
return AuthenticateResult.Fail(new UnauthorizedAccessException());
return Task.FromResult(AuthenticateResult.Fail(new UnauthorizedAccessException()));
}
else
{
Response.StatusCode = 401;
Response.Headers.Add("www-authenticate", "Basic Authorization");
return AuthenticateResult.Fail(new UnauthorizedAccessException());
return Task.FromResult(AuthenticateResult.Fail(new UnauthorizedAccessException()));
}
}
}
Expand Down
14 changes: 0 additions & 14 deletions Configurations/JwtConfiguration.cs

This file was deleted.

4 changes: 2 additions & 2 deletions Filters/EnumSchemaFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public void Apply(OpenApiSchema model, SchemaFilterContext context)
model.Enum.Clear();
foreach (string enumName in Enum.GetNames(context.Type))
{
System.Reflection.MemberInfo? memberInfo = context.Type.GetMember(enumName).FirstOrDefault(m => m.DeclaringType == context.Type);
EnumMemberAttribute? enumMemberAttribute = memberInfo?.GetCustomAttributes(typeof(EnumMemberAttribute), false).OfType<EnumMemberAttribute>().FirstOrDefault();
System.Reflection.MemberInfo memberInfo = context.Type.GetMember(enumName).FirstOrDefault(m => m.DeclaringType == context.Type);
EnumMemberAttribute enumMemberAttribute = memberInfo?.GetCustomAttributes(typeof(EnumMemberAttribute), false).OfType<EnumMemberAttribute>().FirstOrDefault();
string label = enumMemberAttribute == null || string.IsNullOrWhiteSpace(enumMemberAttribute.Value)
? enumName
: enumMemberAttribute.Value;
Expand Down

0 comments on commit 1230626

Please sign in to comment.