File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Host/Startup Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -10,18 +10,22 @@ public class SecurityRequirementsOperationFilter : IOperationFilter
1010 {
1111 public void Apply ( Operation operation , OperationFilterContext context )
1212 {
13- var controllerAbpAuthorizeAttrs = context . ApiDescription . ControllerAttributes ( )
14- . OfType < AbpAuthorizeAttribute > ( ) ;
13+ var actionAttrs = context . ApiDescription . ActionAttributes ( ) ;
14+ if ( actionAttrs . OfType < AbpAllowAnonymousAttribute > ( ) . Any ( ) )
15+ {
16+ return ;
17+ }
1518
16- var actionAbpAuthorizeAtrrs = context . ApiDescription . ActionAttributes ( )
19+ var actionAbpAuthorizeAttrs = actionAttrs . OfType < AbpAuthorizeAttribute > ( ) ;
20+ var controllerAbpAuthorizeAttrs = context . ApiDescription . ControllerAttributes ( )
1721 . OfType < AbpAuthorizeAttribute > ( ) ;
1822
19- if ( controllerAbpAuthorizeAttrs . Any ( ) || actionAbpAuthorizeAtrrs . Any ( ) )
23+ if ( controllerAbpAuthorizeAttrs . Any ( ) || actionAbpAuthorizeAttrs . Any ( ) )
2024 {
2125 operation . Responses . Add ( "401" , new Response { Description = "Unauthorized" } ) ;
2226 operation . Responses . Add ( "403" , new Response { Description = "Forbidden" } ) ;
2327
24- var permissions = controllerAbpAuthorizeAttrs . Union ( actionAbpAuthorizeAtrrs )
28+ var permissions = controllerAbpAuthorizeAttrs . Union ( actionAbpAuthorizeAttrs )
2529 . SelectMany ( p => p . Permissions )
2630 . Distinct ( ) ;
2731
You can’t perform that action at this time.
0 commit comments