Issue integrating DRF (3.5.4) with swagger (2.1)

14 views
Skip to first unread message

Martin Witkowski

unread,
Jul 7, 2017, 1:14:26 PM7/7/17
to Django REST framework
So I've upgraded django+DRF+swagger to the version that now uses the schema generator

The issue is most of my endpoints require authentication through a class that's extending BaseAuthentication, but has custom code to return a user tuple.  These endpoints never get rendered by swagger because they fail the SchemaGenerator class, specifically the get_links method, where its checking has_view_permissions.  When it gets into checking IsAuthenticated, it fails because the user its using is an anonymous user.

I guess that approach is ok, because the swagger endpoints wouldn't be exposed to unauthorized users, but how would they ever become visible through the SchemaGenerator ? The user it gets from the request is not authenticated, and the authorize buttons on swagger merely pass the credentials in the request header.

Do I have to implement my own SchemaGenerator that extracts the header credentials, and authenticates with the correct class per endpoint ?




 
Reply all
Reply to author
Forward
0 new messages