未知
项目描述
Django OAuth Backend 是一组 Django 模型,用于在服务器端实现 OAuth 协议。这些模型可以与各种实现协议HTTP部分的其它项目一起使用。其中一个项目是 lazr.authentication。
用法
用法非常简单。
首先是将此应用程序添加到Django的 INSTALLED_APPS 列表
INSTALLED_APPS = ( ... 'oauth_backend' )
接下来是与 OAuth 协议提供商集成,如 lazr.authentication。看起来可能像这样
# Application's WSGI file from django.core.handlers.wsgi import WSGIHandler from lazr.authentication.wsgi import OAuthMiddleware from oauth_backend.models import DataStore, Consumer, Token def oauth_authenticate(oauth_consumer, oauth_token, parameters): try: consumer = Consumer.objects.get( user__username=oauth_consumer.key ) token = Token.objects.get(token=oauth_token.key) if token.consumer.key == oauth_consumer.key: return consumer.user except (Token.DoesNotExist, Consumer.DoesNotExist): return None django = WSGIHandler() application = OAuthMiddleware( django, authenticate_with=oauth_authenticate, data_store=DataStore(), protect_path_pattern="/protected" )
历史
此代码是从Canonical Identity Provider项目提取出来的。尽管已经额外努力确保所有依赖项都已破坏,并且此代码完全独立,但仍有可能遗漏了一些小问题。在这种情况下,请在项目的错误页面上报告这些错误。
项目详情
关闭
django-oauth-backend-0.2.3.tar.gz的散列
算法 | 散列摘要 | |
---|---|---|
SHA256 | 5e0c49dc1b5f289e9cae3042992f750f6bace6f0c01da9c0cac1849c8651b0e2 |
|
MD5 | 6e275d127ed7cabc86a3e6e8381a09ad |
|
BLAKE2b-256 | 2f0692bf0e3754f9d5fddb111f222a6b5b486eb4c31784da0b5ef17aabc3e9eb |