Ask a Question

Security scheme - how to have a key that's dependendant on the server

xbao
Occasional Visitor

Security scheme - how to have a key that's dependendant on the server

Hello, I have a question about environments and variables.

 

The situation is that I have a production and a staging environment. The auth uses the 'Cookie' header, but with a different key for each environment. E.g.

 

 

GET prod.example.com/test
Cookie:PROD=<access_token>
GET staging.example.com/test
Cookie:STAGING=<access_token>

 

 

How can I represent this in swagger? Following the docs I made the following swagger.json:

{
  "openapi": "3.0.0",
  "info": {
    "version": "1.0.0",
    "title": ""
  },
  "servers": [
    {
      "url": "https://{env}.example.com",
      "variables": {
        "env": {
          "enum": [
            "staging",
            "prod"
          ],
          "default": "prod"
        }
      }
    }
  ],
  "paths": {
    "/test": {
      "get": {
        "security": [
          {
            "UserKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": ""
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "UserKeyAuth": {
        "type": "apiKey",
        "in": "cookie",
        "name": "PROD"
      }
    }
  }
}

Is there any way to say the 'UserKeyAuth' depends on the server env, and include the 'STAGING' key somwhere?

0 REPLIES 0
cancel
Showing results for 
Search instead for 
Did you mean: