Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swagger: ApiSecurityRequirement decorator not working in subcontrollers. #1057

Closed
text2n opened this issue Apr 6, 2022 · 1 comment
Closed
Labels

Comments

@text2n
Copy link

text2n commented Apr 6, 2022

Version of FoalTS: 2.8.1

ApiSecurityRequirement() decorator is not working if defined for subcontrollers.
I have the below controller structure. I have configured ApiController as OpenApi controller. I am trying to make UsersController as Authenticated controller and AuthController as unauthenticated. But if i add ApiSecurityRequirement /JwtRequied on UsersController, actual authentication is working fine, but swagger ui does't consider it as authenticated and is ignoring bearer token in headers.

-AppController
  -ApiController (configured as OpenApi class)
    -UsersController (ApiSecurityRequirement or JwtRequied decorator)
    -AuthController (unauthenticated)

I have created a repo with the sample files here https://github.com/text2n/foalts-test

the openapi.json is as below

{
   "info":{
      "title":"A Great API",
      "version":"1.0.0"
   },
   "openapi":"3.0.0",
   "paths":{
      "/users/":{
         "get":{
            "responses":{
               "401":{
                  "description":"JWT is missing or invalid."
               }
            }
         }
      },
      "/auth/":{
         "get":{
            "responses":{
               
            }
         }
      }
   },
   "servers":[
      {
         "url":"/api"
      }
   ],
   "components":{
      "securitySchemes":{
         "bearerAuth":{
            "bearerFormat":"JWT",
            "scheme":"bearer",
            "type":"http"
         }
      }
   }
}
@text2n text2n added the bug label Apr 6, 2022
@LoicPoullain LoicPoullain added this to Backlog in Issue tracking via automation Apr 6, 2022
@LoicPoullain LoicPoullain moved this from Backlog to Work In Progress in Issue tracking Apr 7, 2022
@LoicPoullain
Copy link
Member

The issue has been fixed and will be released with v2.8.2 👍

Issue tracking automation moved this from Work In Progress to Done / Closed This Release Apr 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Issue tracking
  
Done / Closed This Release
Development

No branches or pull requests

2 participants