我是Django的新手,所以這可能只是在我的知識中顯示出一個巨大的漏洞。我試圖給我們django-openstack-auth驗證我的webapp到Openstack,因爲這兩者將非常緊密地聯繫在一起。然而,我不知道如何讓自定義身份驗證後端工作。我試着按照http://django-openstack-auth.readthedocs.org/en/latest/index.html的說明操作,但是它們有點稀疏,實際上並沒有一個可行的例子。Django Openstack身份驗證
下面是我改變的配置文件,但它的功能不正常,一些大量的谷歌搜索導致我決定我是第一個使用這個模塊(?)的人(實際上,或者我只是最愚蠢的)
settings.py:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
'openstack_auth',
)
#AUTHENTICATION_BACKENDS = ('django.contrib.auth.backends.ModelBackend','openstack_auth.backend.KeystoneBackend',)
AUTHENTICATION_BACKENDS = ('openstack_auth.backend.KeystoneBackend',)
OPENSTACK_KEYSTONE_URL = "http://192.168.XX.XX:35357/v2.0"
urls.py:
from django.conf.urls import patterns, include, url
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
url(r'', include('openstack_auth.urls')),
)
我甚despirate,並試圖在一個視圖中手動驗證,但是這只是公關oduces驗證錯誤太...
from django.http import HttpResponse
from django.contrib.auth import authenticate, login
def home(request):
user = authenticate(username='user', password='password')
if user is None:
login(request, user)
else:
return HttpResponse("Hello")
任何指針將大規模感激...
非常感謝
亞歷