File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Host/Startup Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -10,28 +10,28 @@ public class SecurityRequirementsOperationFilter : IOperationFilter
10
10
{
11
11
public void Apply ( Operation operation , OperationFilterContext context )
12
12
{
13
- var actionAttrs = context . ApiDescription . ActionAttributes ( ) ;
13
+ var actionAttrs = context . ControllerActionDescriptor . MethodInfo . GetCustomAttributes ( true ) . ToList ( ) ;
14
14
if ( actionAttrs . OfType < AbpAllowAnonymousAttribute > ( ) . Any ( ) )
15
15
{
16
16
return ;
17
17
}
18
18
19
- var controllerAttrs = context . ApiDescription . ControllerAttributes ( ) ;
20
- var actionAbpAuthorizeAttrs = actionAttrs . OfType < AbpAuthorizeAttribute > ( ) ;
19
+ var controllerAttrs = context . ControllerActionDescriptor . ControllerTypeInfo . GetCustomAttributes ( true ) ;
20
+ var actionAbpAuthorizeAttrs = actionAttrs . OfType < AbpAuthorizeAttribute > ( ) . ToList ( ) ;
21
21
22
22
if ( ! actionAbpAuthorizeAttrs . Any ( ) && controllerAttrs . OfType < AbpAllowAnonymousAttribute > ( ) . Any ( ) )
23
23
{
24
24
return ;
25
25
}
26
26
27
- var controllerAbpAuthorizeAttrs = controllerAttrs . OfType < AbpAuthorizeAttribute > ( ) ;
27
+ var controllerAbpAuthorizeAttrs = controllerAttrs . OfType < AbpAuthorizeAttribute > ( ) . ToList ( ) ;
28
28
if ( controllerAbpAuthorizeAttrs . Any ( ) || actionAbpAuthorizeAttrs . Any ( ) )
29
29
{
30
30
operation . Responses . Add ( "401" , new Response { Description = "Unauthorized" } ) ;
31
31
32
32
var permissions = controllerAbpAuthorizeAttrs . Union ( actionAbpAuthorizeAttrs )
33
33
. SelectMany ( p => p . Permissions )
34
- . Distinct ( ) ;
34
+ . Distinct ( ) . ToList ( ) ;
35
35
36
36
if ( permissions . Any ( ) )
37
37
{
You can’t perform that action at this time.
0 commit comments