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

Private endpoints remain hidden after authorizing #342

Closed
adlmtl opened this issue Mar 19, 2021 · 5 comments
Closed

Private endpoints remain hidden after authorizing #342

adlmtl opened this issue Mar 19, 2021 · 5 comments
Labels
enhancement New feature or request fix confirmation pending issue has been fixed and confirmation from issue reporter is pending help wanted Extra attention is needed

Comments

@adlmtl
Copy link

adlmtl commented Mar 19, 2021

Using SERVE_PUBLIC=True as shown in the docs. After fetching a jwt token and authorizing in the swagger-ui the page does not reload, and I am still only able to see public endpoints.

I've also tried refreshing the page manually with persistAuthorization = True being set and still no luck.

However if i call the schema endpoint it does return my complete schema with all private endpoints if I am authorized, it just doesn't reflect this in the swagger-ui

SPECTACULAR_SETTINGS = {
        'SERVE_PUBLIC': False,

        "SWAGGER_UI_SETTINGS": {
            "persistAuthorization": True,
        },
    }

I'm using simpleJWT for auth.

@tfranzel
Copy link
Owner

hi @adlmtl, interesting! so that would basically mean that the JWT token is not sent by SwaggerUI when requesting the schema url.

that kind of makes sense somehow. the JWT token is used by SwaggerUI for building requests but it is no used by it's own bootstrapping. this all works automatically when cookie auth is used, but for JWT one must explicit set a header, which is why it fails here.

SwaggerUI would have to be modified so that the schema url is reloaded on auth and also that the authorization is reused for requesting the schema.

@adlmtl
Copy link
Author

adlmtl commented Mar 19, 2021

yasg behaves this way, so there's probably something that can be done. Any thoughts how I could progress? Thanks for responding so quickly!

@tfranzel
Copy link
Owner

ahh i see. yes, yasg has a more hands-on approach to SwaggerUI. they have a custom init logic and patches going on, whereas we currently use only plain upstream SwaggerUI. this may be the first time we reached the limit of upstream SwaggerUI.

the magic is here:
https://github.com/axnsan12/drf-yasg/blob/9ccf24c27ad46db4f566170553d49d687b6d21d6/src/drf_yasg/static/drf-yasg/swagger-ui-init.js#L162

we may have to patch SwaggerUI init logic for this. happy to look at proposals here as i'm lacking the time to tackle this atm.

@tfranzel tfranzel added the enhancement New feature or request label Mar 19, 2021
@tfranzel tfranzel added the help wanted Extra attention is needed label Apr 3, 2021
@tfranzel
Copy link
Owner

tfranzel commented Oct 6, 2021

please review and test #552

@tfranzel tfranzel added the fix confirmation pending issue has been fixed and confirmation from issue reporter is pending label Oct 6, 2021
tfranzel added a commit that referenced this issue Oct 31, 2021
Swagger UI authorized schema retrieval #342 #458
@tfranzel
Copy link
Owner

closing this issue for now. feel free to comment if anything is missing or not working and we will follow-up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fix confirmation pending issue has been fixed and confirmation from issue reporter is pending help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants