Esempio n. 1
0
    def process_view(self, request, view_func, view_args, view_kwargs):
        logout = LogoutView.as_view().__name__
        is_logout = view_func.__name__ == logout
        is_login = view_func.__name__ == LoginView.as_view().__name__

        if is_login or is_logout:
            return None

        if view_func.__name__ == CasLogin.__name__:
            return CasLogin(request, *view_args, **view_kwargs)
        elif is_logout:
            return CasLogout.as_view(request, *view_args, **view_kwargs)

        if settings.CAS_ADMIN_PREFIX:
            if not request.path.startswith(settings.CAS_ADMIN_PREFIX):
                return None
        elif not view_func.__module__.startswith('django.contrib.admin.'):
            return None

        if request.user.is_authenticated:
            if request.user.has_perm('wagtailadmin.access_admin'):
                """
                Implemented using wagtails permissions model
                https://github.com/torchbox/wagtail/blob/master/wagtail/wagtailadmin/views/account.py#L112 # noqa
                """
                return None
            else:
                return permission_denied(request, HttpResponseForbidden)
        return super(MoloCASMiddleware, self).process_view(
            request, view_func, view_args, view_kwargs)
Esempio n. 2
0
from django.conf.urls import url
from django_cas_ng.views import LoginView, LogoutView, CallbackView

urlpatterns = [
    url(r'^login/$', LoginView.as_view(), name='cas_ng_login'),
    url(r'^logout/$', LogoutView.as_view(), name='cas_ng_logout'),
    url(r'^callback/$', CallbackView.as_view(), name='cas_ng_proxy_callback'),
]
Esempio n. 3
0
admin.site.site_header = 'CCA Libraries Administration'
admin.autodiscover()

urlpatterns = [
    path('django-admin/', admin.site.urls),
    # override Wagtail document handling — send file, not a forced download
    path('documents/<int:document_id>/<document_filename>',
         serve_wagtail_doc,
         name='wagtaildocs_serve'),

    # CAS login urls
    # NOTE: ^admin/logout/$ must appear before ^admin/ or it's impossible to logout
    path('login/', LoginView.as_view(), name='cas_ng_login'),
    path('admin/login/', LoginView.as_view()),
    path('admin/logout/', LogoutView.as_view(), name='cas_ng_logout'),
    path('admin/', include(wagtailadmin_urls)),
    # @TODO can we do this using just Wagtail REST APIs instead of Django REST framework?
    path('api/v2/', api_router.urls),
    path('api/v1/', include('alerts.urls')),
    path('search/', search_views.search, name='search'),
    path('hours/', hours_views.hours, name='hours'),

    # Summon "broken links" app
    path('brokenlinks/', brokenlinks_views.brokenlinks, name='brokenlinks'),

    # Serials Solution API proxy
    path('sersol/', sersol_views.sersol, name='sersol_api'),

    # Favicon
    path(