Django:一种视图的基本身份验证(避免使用中间件) [英] Django: Basic Auth for one view (avoid middleware)
本文介绍了Django:一种视图的基本身份验证(避免使用中间件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要为一个视图提供http-basic-auth
.
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 filled in by a remote application.
推荐答案
可以使用此库: https: //github.com/hirokiky/django-basicauth
Django的基本身份验证实用程序.
Basic auth utilities for Django.
文档显示了如何使用它:
The docs show how to use it:
将装饰器应用于CBV
Applying decorator to CBVs
要将@basic_auth_requried装饰器应用于基于类的视图,请使用 django.utils.decorators.method_decorator.
To apply @basic_auth_requried decorator to Class Based Views, use django.utils.decorators.method_decorator.
来源: https://github.com/hirokiky/django- basicauth#applying-decorator-cbvs
这篇关于Django:一种视图的基本身份验证(避免使用中间件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文