www-bocal/bocal/urls.py
Théophile Bastian eed3653d22 Use rhosts file to grant permissions to users.
Whenever a user logs in through CAS, their username is looked up in the
.rhosts file provided through settings. If it is found, the user is
granted staff status and BOcal group (cf fixture).

The rights are re-evaluated at each login and at each access to
/admin/login.

Close #2.
2017-10-14 19:36:13 +02:00

54 lines
1.8 KiB
Python

"""bocal URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url, include
from django.contrib import admin
from django.contrib.auth.decorators import login_required
import django.contrib.auth.views as dj_auth_views
import mainsite.urls
import bocal_auth.views as auth_views
from bocal_auth.rhosts import forceReevalRhosts
import markdownx.urls
import api.urls
import django_cas_ng.views
# Force the user to login through the custom login page
admin.site.login = login_required(forceReevalRhosts(admin.site.login))
cas_patterns = [
url(r'^login$', django_cas_ng.views.login, name='cas_ng_login'),
url(r'^logout$', django_cas_ng.views.logout, name='cas_ng_logout'),
url(r'^callback$', django_cas_ng.views.callback,
name='cas_ng_proxy_callback'),
]
accounts_patterns = [
url(r'^cas/', include(cas_patterns)),
url(r'^login$', auth_views.login, name='login'),
url(r'^logout$', auth_views.logout, name='logout'),
url(r'^password_login$', dj_auth_views.LoginView.as_view(),
name='password_login'),
]
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^markdownx/', include(markdownx.urls)),
url(r'^api/', include(api.urls)),
url(r'^accounts/', include(accounts_patterns)),
url(r'^', include(mainsite.urls)),
]