看这一篇吧 https://blog.csdn.net/u014686399/article/details/105097217, 是最新的。这篇太老了
这两天废了九牛二虎之力完成了python3.5接入cas server, 废话少说,步骤如下:
python | 3.5.4 |
django | 2.0 |
对接的cas server | 3.5.2 |
unique_together = ('session_key', 'user')
session_key = models.CharField(max_length=255, blank=True, null=True)
user = models.ForeignKey(
settings.AUTH_USER_MODEL,
related_name="+",
null=True,
blank=True,on_delete=models.PROTECT
)
3、django_cas_ng.ProxyGrantingTicket.date: (fields.E160) The options auto_now, auto_now_add, and default are mutually exclusive. Only one of these options may be present.
pgtiou = models.CharField(max_length=255, null=True, blank=True)
pgt = models.CharField(max_length=255, null=True, blank=True)
date = models.DateTimeField(auto_now_add=True)
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_cas_ng',
...
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
...
)
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'django_cas_ng.backends.CASBackend',
)
添加 CAS_SERVER_URL="cas server的地址"
添加 CAS_REDIRECT_URL="你网站的主页"
url(r'^accounts/login$', django_cas_ng.views.login, name='cas_ng_login'),
url(r'^accounts/logout$', django_cas_ng.views.logout, name='cas_ng_logout'),
url(r'^accounts/callback$', django_cas_ng.views.callback, name='cas_ng_proxy_callback'),
openssl x509 -inform der -in server.cer -out server.pemaccounts/login