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

Add parameter config.SWAGGER_UI_OAUTH_REDIRECT_URL #544

Open
aparamon opened this issue Oct 25, 2018 · 0 comments
Open

Add parameter config.SWAGGER_UI_OAUTH_REDIRECT_URL #544

aparamon opened this issue Oct 25, 2018 · 0 comments

Comments

@aparamon
Copy link

Currently, Swagger has oauth2RedirectUrl parameter always hard-coded to "http://localhost:3200/oauth2-redirect.html". It is sub-optimal: Flask-Restplus should respect config.SWAGGER_UI_OAUTH_REDIRECT_URL similar to config.SWAGGER_UI_OAUTH_CLIENT_ID, config.SWAGGER_UI_OAUTH_APP_NAME, config.SWAGGER_UI_OAUTH_REALM.

SteadBytes pushed a commit that referenced this issue Aug 11, 2019
The swagger-ui project contains a 'oauth2-redirect.html' file
which provides a credential trampoline. Vendor it in, and
place the external url to this file in swagger-ui.html.

The OAuth2 authentication loop is run in a popup window/tab.
The IDP will redirect back to the oauth2RedirectUrl with an
access_token provided in the #hash-fragment of the url.
Javascript running inside 'oauth2-redirect.html' pushes the
access_token back to the parent which created the window/tab,
before closing the tab.

Enables use-case in #544 without adding another config param.

Usage:

```python
app.config.SWAGGER_UI_OAUTH_CLIENT_ID = 'MyClientId'
app.config.SWAGGER_UI_OAUTH_REALM = '-'
app.config.SWAGGER_UI_OAUTH_APP_NAME = 'Demo'
api = Api(
    app,
    title='Demo',
    security={'OAuth2': ['read', 'write']},
    authorizations={
        'OAuth2': {
            'type': 'oauth2',
            'flow': 'implicit',
            'authorizationUrl': 'https://idp.example.com/authorize?audience=https://app.example.com',
            'clientId': app.config.SWAGGER_UI_OAUTH_CLIENT_ID,
            'scopes': {
                'openid': 'Get ID token',
                'profile': 'Get identity',
            }
        }
    }
)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant