Correctly set scopes for AuthorizeCheckOperationFilter
This commit is contained in:
parent
3858d7ccf7
commit
9c2b972cc9
@ -6,9 +6,11 @@ using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
namespace Services.Common;
|
||||
internal class AuthorizeCheckOperationFilter : IOperationFilter
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
public AuthorizeCheckOperationFilter(IConfiguration configuration)
|
||||
{
|
||||
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public void Apply(OpenApiOperation operation, OperationFilterContext context)
|
||||
@ -27,11 +29,14 @@ internal class AuthorizeCheckOperationFilter : IOperationFilter
|
||||
Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "oauth2" }
|
||||
};
|
||||
|
||||
var identitySection = _configuration.GetSection("Identity");
|
||||
var scopes = identitySection.GetRequiredSection("Scopes").GetChildren().Select(r => r.Key).ToArray();
|
||||
|
||||
operation.Security = new List<OpenApiSecurityRequirement>
|
||||
{
|
||||
new()
|
||||
{
|
||||
[ oAuthScheme ] = new [] { "basketapi" }
|
||||
[ oAuthScheme ] = scopes
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user