Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Commit 9c2b972

Browse files
committed
Correctly set scopes for AuthorizeCheckOperationFilter
1 parent 3858d7c commit 9c2b972

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Services/Services.Common/AuthorizeCheckOperationFilter.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
namespace Services.Common;
77
internal class AuthorizeCheckOperationFilter : IOperationFilter
88
{
9+
private readonly IConfiguration _configuration;
10+
911
public AuthorizeCheckOperationFilter(IConfiguration configuration)
1012
{
11-
13+
_configuration = configuration;
1214
}
1315

1416
public void Apply(OpenApiOperation operation, OperationFilterContext context)
@@ -27,11 +29,14 @@ public void Apply(OpenApiOperation operation, OperationFilterContext context)
2729
Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "oauth2" }
2830
};
2931

32+
var identitySection = _configuration.GetSection("Identity");
33+
var scopes = identitySection.GetRequiredSection("Scopes").GetChildren().Select(r => r.Key).ToArray();
34+
3035
operation.Security = new List<OpenApiSecurityRequirement>
3136
{
3237
new()
3338
{
34-
[ oAuthScheme ] = new [] { "basketapi" }
39+
[ oAuthScheme ] = scopes
3540
}
3641
};
3742
}

0 commit comments

Comments
 (0)