Django: Basic Auth for one view (avoid middleware)

前端 未结 4 1153
星月不相逢
星月不相逢 2021-02-18 23:46

I need to provide http-basic-auth to one view.

I want to avoid modifying the middleware settings.

Background: This is a view which gets fil

4条回答
  •  无人共我
    2021-02-19 00:10

    This library could be used: https://github.com/hirokiky/django-basicauth

    Basic auth utilities for Django.

    The docs show how to use it:

    Applying decorator to CBVs

    To apply @basic_auth_requried decorator to Class Based Views, use django.utils.decorators.method_decorator.

    Source: https://github.com/hirokiky/django-basicauth#applying-decorator-to-cbvs

提交回复
热议问题