Handle multiple environments for authorizationUrl and tokenUrl in Open API spec

Viewed 962

Is it possible to somehow template the base path for authorizationUrl and tokenUrl in an oauth2 security scheme to handle multiple environments (e.g. dev, sit, uat)?

The company where I work has a separate IDP tenant per environment and services in each environment will validate tokens against a specific tenant/issuer.

Ideally I could define and select the tenant base URL similar to how I can template servers for API routes - see here.
enter image description here

My securitySchemes currently looks like this:

"securitySchemes": {
    "oauth": {
        "type": "oauth2",
        "flows": {
            "authorizationCode": {
                "authorizationUrl": "https://tenant-dev.au.auth0.com/authorize?audience=test",
                "tokenUrl": "https://tenant-dev.au.auth0.com/oauth/token"
            }
        }
    }
}

The only multi-environment approach that I can think of so far is to use the following security scheme config which allows me to specify any JWT. The drawback is that I still need to obtain the JWT by some external means...

"securitySchemes": {
    "oauth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
    }
}

Notes;

  • we're using external IDP so the IDP base URL does not overlap with the service base URLs.
  • Swagger UI won't be accessible in production environment, but there's still dev, sit and uat.
0 Answers
Related