# -*- coding: utf-8 -*- from django.conf import settings from django.conf.urls import patterns, url, include from django.http import HttpResponse from simple_sso.sso_client.client import Client from simple_sso.sso_server.server import Server test_server = Server() test_client = Client(settings.SSO_SERVER, settings.SSO_PUBLIC_KEY, settings.SSO_PRIVATE_KEY) urlpatterns = patterns('', url(r'^server/', include(test_server.get_urls())), url(r'^client/', include(test_client.get_urls())), url(r'^login/$', 'django.contrib.auth.views.login', {'template_name': 'admin/login.html'}), url('^$', lambda request: HttpResponse('home'), name='root') )
Including another URLconf 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.conf.urls import url # from filebrowser.sites import site from django.contrib import admin from django.urls import path, include from core import views from django.conf.urls.static import static from prototype.settings import settings from simple_sso.sso_server.server import Server from simple_sso.sso_client.client import Client sso_server = Server() sso_client = Client(settings.SSO_SERVER, settings.SSO_PUBLIC_KEY, settings.SSO_PRIVATE_KEY) urlpatterns = [ # path('admin/filebrowser/', site.urls), # path('grappelli/', include('grappelli.urls')), path('admin/', admin.site.urls), path('', views.index, name='index'), path('register/', views.register, name='register'), path('login/', views.login, name='login'), url(r'^server/', include(sso_server.get_urls())), path('authorize/', views.authorize, name='authorize'), path('client/', include(sso_client.get_urls())) ] urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
from rest_framework.authentication import SessionAuthentication, BasicAuthentication from rest_framework.permissions import IsAuthenticated from django.conf import settings from simple_sso.sso_client.client import Client from lucommon import settings as lusettings """ Authentication and Permissions """ class LuAuthPerm(object): """ Process auth and perm related """ authentication_classes = (SessionAuthentication, BasicAuthentication) if lusettings.AUTH else () permission_classes = (IsAuthenticated, ) if lusettings.PERM else () sso_client = Client(settings.SSO_SERVER, settings.SSO_PUBLIC_KEY, settings.SSO_PRIVATE_KEY) if hasattr( settings, 'SSO_SERVER') else None
# pylint: disable=no-self-use return Post.objects.filter(timestamp__lt=timezone.now()).order_by("-timestamp") def lastmod(self, item): # pylint: disable=no-self-use return item.timestamp # create each section in all languages SITEMAPS = {lang[0]: PagesSitemap(lang[0]) for lang in settings.LANGUAGES} SITEMAPS["news"] = NewsSitemap() UUID = r"(?P<pk>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})" SSO_CLIENT = Client( settings.SSO_SERVER, settings.SSO_PUBLIC_KEY, settings.SSO_PRIVATE_KEY ) urlpatterns = i18n_patterns( url(r"^$", TemplateView.as_view(template_name="index.html"), name="home"), url( r"^features/$", TemplateView.as_view(template_name="features.html"), name="features", ), url(r"^tour/$", RedirectView.as_view(url="/hosting/", permanent=True)), url( r"^download/$", TemplateView.as_view(template_name="download.html"), name="download",
Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: path('', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') Including another URLconf 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin from django.urls import path from django.views.generic import TemplateView from django.conf import settings from simple_sso.sso_client.client import Client test_client = Client(settings.SSO_SERVER, settings.SSO_PUBLIC_KEY, settings.SSO_PRIVATE_KEY) urlpatterns = [ path('admin/', admin.site.urls), path('client/', test_client.login_view.as_view(client=test_client), name='simple-sso-login'), path('client/authenticate/', test_client.authenticate_view.as_view(client=test_client), name='simple-sso-authenticate'), path('', TemplateView.as_view(template_name='base.html'), name='home') ]
# Django specific from django.conf import settings from django.conf.urls import patterns, include, url from django.contrib import admin from django.contrib.auth.decorators import login_required from django.core.urlresolvers import reverse, reverse_lazy from django.http import HttpResponse # App specific from simple_sso.sso_client.client import Client admin.autodiscover() admin.site.login = login_required(admin.site.login, login_url=reverse_lazy(settings.LOGIN_URL)) sso_client = Client(settings.SSO_SERVER, settings.SSO_PUBLIC_KEY, settings.SSO_PRIVATE_KEY) urlpatterns = patterns("", url(r"^auth/", include(sso_client.get_urls())), url(r"^admin/", include(admin.site.urls))) # App mock urlpatterns += patterns( "", url( "^$", lambda request: HttpResponse( 'Welcome at the <strong>client</strong> visit <a href="/secret/">secret</a> or <a href="/admin/">admin</a>.' ), ), url( "^secret/$", login_required(lambda request: HttpResponse("Secret at the client"), login_url=reverse(settings.LOGIN_URL)), name="root",
def lastmod(self, item): # pylint: disable=no-self-use return item.timestamp # create each section in all languages SITEMAPS = { lang[0]: PagesSitemap(lang[0]) for lang in settings.LANGUAGES } SITEMAPS['news'] = NewsSitemap() UUID = r'(?P<pk>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})' SSO_CLIENT = Client( settings.SSO_SERVER, settings.SSO_PUBLIC_KEY, settings.SSO_PRIVATE_KEY ) urlpatterns = i18n_patterns( url( r'^$', TemplateView.as_view(template_name="index.html"), name='home' ), url( r'^features/$', TemplateView.as_view(template_name="features.html"), name='features' ), url(
from django.conf.urls import patterns, include, url from django.contrib import admin from simple_sso.sso_client.client import Client from django.conf import settings sso_client = Client(server_url=settings.SSO_SERVER_URL, public_key=settings.SSO_PUBLIC_KEY, private_key=settings.SSO_PRIVATE_KEY) urlpatterns = patterns( '', url(r'^sso/', include(sso_client.get_urls())), url(r'^$', 'docs.views.home', name='home'), url(r'^login/$', 'docs.views.login', name='login'), url(r'^logout/$', 'docs.views.logout', name='logout'), url(r'^preview/$', 'docs.views.preview', name='preview'), url(r'^(?P<project_url>.*)/(?P<page_url>.*)/last-version/$', 'docs.views.get_last_version', name='view'), url(r'^(?P<project_url>.*)/(?P<page_url>.*)/edit/$', 'docs.views.edit', name='edit'), url(r'^(?P<project_url>.*)/(?P<page_url>.*)/$', 'docs.views.view', name='view'), # Examples: # url(r'^$', 'docs.views.home', name='home'), # url(r'^blog/', include('blog.urls')), # url(r'^admin/', include(admin.site.urls)), )