lukeautry / tsoa

Build OpenAPI-compliant REST APIs using TypeScript and Node
MIT License
3.48k stars 498 forks source link

Declare Auth schema without need to implement handlers #1615

Closed mishelen closed 4 months ago

mishelen commented 5 months ago

Sorting

Expected Behavior

Suppose I have tsoa.json:

  "spec": {
    "outputDirectory": "src",
    "specVersion": 3,
    "securityDefinitions": {
      "AuthorizationHeader": {
        "type": "apiKey",
        "in": "header",
        "name": "Authorization"
      }
    }
  },

So I want to add authorization. But problem is in fact that it will currently not applied to any of endpoints when making swagger requests. To add it, I need to specify "rootSecurity": [{ "AuthorizationHeader": []}] and then provide AuthorizationModule, while authorization is done externally via lambda auth.

Question is how to provide authorization schema and apply globally without need to implement it?

Context (Environment)

Version of the library: 6.2.0 Version of NodeJS: 20.12.2

github-actions[bot] commented 5 months ago

Hello there mishelen 👋

Thank you for opening your very first issue in this project.

We will try to get back to you as soon as we can.👀

github-actions[bot] commented 4 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

mohamedsalah2024 commented 2 months ago

@mishelen did you solve it?

mishelen commented 1 month ago

@mishelen did you solve it?

yes, I just mutate swagger doc adding all security rules by hand