Skip to content

Making the OpenAPI docs only available to authenticated users #1893

Closed Answered by scott2b
scott2b asked this question in Q&A
Discussion options

You must be logged in to vote

It turns out that I had "/schema" as an exclude path on my SessionAuth instance. I removed that and my approach above now seems to be working. The gist of it is simply to subclass OpenAPIController and provide it with whatever guards you would normally use on a controller for your authentication approach:

from litestar.openapi import OpenAPIController

class CustomDocController(OpenAPIController):
    guards = [myguard]

Then specify that as the openapi_controller on the OpenAPIConfig.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Goldziher
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant