Skip to content
Permalink
Browse files
Add django-cas-ng integration
  • Loading branch information
Ming committed Jan 22, 2020
1 parent e740c09 commit 4dea11de05e0730b4e881e4ba64d2d39e7fa690a
Showing 4 changed files with 25 additions and 1 deletion.
BIN +144 KB db.sqlite3
Binary file not shown.
@@ -26,7 +26,8 @@
DEBUG = True

ALLOWED_HOSTS = [
'django-cas-ng-demo.herokuapp.com'
'django-cas-ng-demo.herokuapp.com',
'localhost',
]


@@ -39,6 +40,7 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_cas_ng'
]

MIDDLEWARE = [
@@ -49,8 +51,14 @@
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django_cas_ng.middleware.CASMiddleware'
]

AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'django_cas_ng.backends.CASBackend',
)

ROOT_URLCONF = 'mysite.urls'

TEMPLATES = [
@@ -101,6 +109,9 @@
},
]

CAS_SERVER_URL = 'https://django-cas-ng-demo-server.herokuapp.com/cas/'
CAS_VERSION = '3'


# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/
@@ -15,7 +15,12 @@
"""
from django.contrib import admin
from django.urls import path
import django_cas_ng.views
from . import views

urlpatterns = [
path('', views.index, name='index'),
path('admin/', admin.site.urls),
path('accounts/login', django_cas_ng.views.LoginView.as_view(), name='cas_ng_login'),
path('accounts/logout', django_cas_ng.views.LogoutView.as_view(), name='cas_ng_logout'),
]
@@ -0,0 +1,8 @@
from django.http import HttpResponse


def index(request):
if request.user.is_authenticated:
return HttpResponse('<p>Welcome to <a href="https://djangocas.dev">django-cas-ng</a>.</p><p>You logged in as <strong>%s</strong>.</p><p><a href="/accounts/logout">Logout</a></p>' % request.user)
else:
return HttpResponse('<p>Welcome to <a href="https://djangocas.dev">django-cas-ng</a>.</p><p><a href="/accounts/login">Login</a></p>')

0 comments on commit 4dea11d

Please sign in to comment.