Skip to content

Add swagger UI oauth2 redirect page#198

Merged
tiangolo merged 3 commits into
fastapi:masterfrom
steinitzu:swagger-oauth
May 21, 2019
Merged

Add swagger UI oauth2 redirect page#198
tiangolo merged 3 commits into
fastapi:masterfrom
steinitzu:swagger-oauth

Conversation

@steinitzu

Copy link
Copy Markdown
Contributor

I added the oauth2 redirect page from swagger-ui (html/js copied from https://github.com/swagger-api/swagger-ui/blob/master/dist/oauth2-redirect.html )
It's mounted to the app under /{docs_url}/oauth2-redirect

This is needed for implicit grant Oauth2 flow in swagger ui, so it can grab the token on redirect, e.g. this kind of security scheme:

from fastapi.security import OAuth2
from fastapi.openapi.models import OAuthFlows, OAuthFlowImplicit

oauth2_scheme = OAuth2(
    flows=OAuthFlows(
        implicit=OAuthFlowImplicit(
            authorizationUrl="https://some/oauth2/provider/login/url"
        )
    )
)

@codecov

codecov Bot commented May 2, 2019

Copy link
Copy Markdown

Codecov Report

Merging #198 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #198   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files         175    177    +2     
  Lines        4268   4327   +59     
=====================================
+ Hits         4268   4327   +59
Impacted Files Coverage Δ
tests/test_custom_swagger_ui_redirect.py 100% <100%> (ø)
tests/test_no_swagger_ui_redirect.py 100% <100%> (ø)
fastapi/applications.py 100% <100%> (ø) ⬆️
fastapi/openapi/docs.py 100% <100%> (ø) ⬆️
tests/test_application.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 08322ef...0710ca2. Read the comment docs.

@tiangolo

Copy link
Copy Markdown
Member

Thanks! Interesting. I'll check it soon.

@tiangolo
tiangolo merged commit 325edd5 into fastapi:master May 21, 2019
@tiangolo

Copy link
Copy Markdown
Member

Thank you @steinitzu !

I just updated/refactored it a bit, to make it optional and to make the URL path for the redirection parameterizable.

It is now merged! 🎉 🚀

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

Successfully merging this pull request may close these issues.

2 participants