From: Łukasz Rekucki Date: Sat, 17 Apr 2010 13:34:42 +0000 (+0200) Subject: Some cleanup before production deploy. X-Git-Url: https://git.mdrn.pl/cas.git/commitdiff_plain/a7d807af1096c152baf5c32f4f4b3f1a26ea2c76?hp=e236585868829946444ac537adbbf481782ecb8f Some cleanup before production deploy. --- diff --git a/README.md b/README.md new file mode 100644 index 0000000..d63f735 --- /dev/null +++ b/README.md @@ -0,0 +1,32 @@ +O projekcie +----------- + +CAS to aplikacja WWW służąca do uwierzytelniania (a w przyszłości również autoryzacji) użytkowników +serwisów Fundacji Nowoczesna Polska. Implementuje on protokół CAS w +wersji 1.0. + +Wymagania +--------- + +* Django 1.1 +* zuber/django-cas-provider + +Instalacja i uruchomienie +------------------------- + +1. Ściągnij i zainstaluj pip +2. Przejdź do katalogu aplikacji w konsoli +3. Zainstaluj wymagane biblioteki (patrz sekcja wymagania_) komendą + + pip install -r requirements.txt + +4. Wypełnij bazę danych (Django poprosi o utworzenie pierwszego użytkownika) + + ./manage.py syncdb + +5. Uruchom serwer deweloperski + + ./manage.py runserver + +6. Przy wdrożeniu będziesz musiał najpewniej utworzyć plik `localsettings.py` i wpisać tam +ustawienia używanej bazy danych. Zalecane jest serwowanie aplikacji przez modwsgi na serwerze Apache2. \ No newline at end of file diff --git a/README.rst b/README.rst deleted file mode 100644 index bccda5b..0000000 --- a/README.rst +++ /dev/null @@ -1,36 +0,0 @@ -================================ -Fundacja Nowoczesna Polska - CAS -================================ - -O projekcie -=========== -CAS to aplikacja WWW służąca do autentykacji (a w przyszłości również autoryzacji) użytkowników -serwisów Fundacji Nowoczesna Polska. Implementuje on protokół `CAS `_ w -wersji 1.0. - -Wymagania -========= -* `Django 1.1 `_ -* `zuber/django-cas-provider `_ - -Instalacja i uruchomienie -========================= -1. Ściągnij i zainstaluj `pip `_ -2. Przejdź do katalogu aplikacji w konsoli -3. Zainstaluj wymagane biblioteki (patrz sekcja wymagania_) komendą:: - - pip install -r requirements.txt - -4. Wypełnij bazę danych (Django poprosi o utworzenie pierwszego użytkownika):: - - ./manage.py syncdb - -5. Uruchom serwer deweloperski:: - - ./manage.py runserver - -6. Przy wdrożeniu będziesz musiał najpewniej utworzyć plik `localsettings.py` i wpisać tam -ustawienia używanej bazy danych. Zalecane jest serwowanie aplikacji -przez `modwsgi `_ na serwerze `Apache2 `_ -przy pomocy załączonego skryptu `dispatch.fcgi`. Inne strategie wdrożeniowe opisane -są w `Dokumentacji Django `_. \ No newline at end of file diff --git a/cas.vhost.template b/cas.vhost.template new file mode 100644 index 0000000..d951258 --- /dev/null +++ b/cas.vhost.template @@ -0,0 +1,51 @@ + + ServerName $DOMAIN + ServerAlias $DOMAIN_ALIASES + + ServerAdmin $ADMIN_EMAIL + + Alias /robots.txt $MEDIA_ROOT/static/robots.txt + Alias /favicon.ico $MEDIA_ROOT/static/favicon.ico + + Alias /media/ $MEDIA_ROOT + + # + # Logs + LogLevel info + + # + # WSGI configuration follows + # + + WSGIDaemonProcess $PROJECT_NAME processes=2 threads=1 user=$WSGI_USER group=$WSGI_USER display-name=%{GROUP} + WSGIProcessGroup $PROJECT_NAME + WSGIScriptAlias / $WSGI_TARGET + + + Order allow,deny + Allow from all + + + + # Insert filter + SetOutputFilter DEFLATE + + # Don't compress images + SetEnvIfNoCase Request_URI \ + \.(?:xsl|xml|json|gif|jpe?g|png)$ no-gzip dont-vary + + + + Order allow,deny + Allow from all + + + # + # Header unset ETag + # FileETag None + # ExpiresActive On + # ExpiresDefault "now plus 1 year" + # + + + \ No newline at end of file diff --git a/cas.wsgi.template b/cas.wsgi.template index 2124c1e..d8c87da 100644 --- a/cas.wsgi.template +++ b/cas.wsgi.template @@ -1,6 +1,6 @@ -#!%(python)s +#!$PYTHON import site -site.addsitedir('%(path)s/lib/python2.5/site-packages') +site.addsitedir('$PYTHON_SITE') import os from os.path import abspath, dirname, join @@ -12,13 +12,12 @@ sys.stdout = sys.stderr # Add apps and lib directories to PYTHONPATH sys.path = [ - '%(path)s/releases/current/%(project_name)s', - '%(path)s/releases/current/provider', - '%(path)s/releases/current', + '$PROJECT_ROOT/src', + '$PROJECT_ROOT/provider', ] + sys.path # Run Django -os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' +os.environ['DJANGO_SETTINGS_MODULE'] = '$PROJECT_NAME.settings' from django.core.handlers.wsgi import WSGIHandler application = WSGIHandler() diff --git a/cas/__init__.py b/cas/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/cas/logging.cfg b/cas/logging.cfg deleted file mode 100644 index ce758bc..0000000 --- a/cas/logging.cfg +++ /dev/null @@ -1,34 +0,0 @@ -[loggers] -keys=root,fnp - -[handlers] -keys=console,lf - -[formatters] -keys=default - -[logger_root] -level=DEBUG -handlers=console - -[logger_fnp] -level=DEBUG -handlers=lf,console -qualname=fnp -propagate=0 - -[formatter_default] -format=%(asctime)s %(name)s/%(levelname)s :: %(module)s:%(lineno)d :: %(message)s -datefmt= - -[handler_console] -class=StreamHandler -level=DEBUG -formatter=default -args=(sys.stderr, ) - -[handler_lf] -class=FileHandler -level=DEBUG -formatter=default -args=("/var/services/logs/cas.log",) \ No newline at end of file diff --git a/cas/manage.py b/cas/manage.py deleted file mode 100755 index 741587d..0000000 --- a/cas/manage.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python -from django.core.management import execute_manager - -from os import path -import sys - -PROJECT_ROOT = path.realpath(path.dirname(__file__)) -sys.path.insert(0, path.abspath(path.join(PROJECT_ROOT, "..", "provider"))) -print sys.path - -try: - import settings # Assumed to be in the same directory. -except ImportError: - import traceback - traceback.print_exc(file =sys.stderr) - sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__) - sys.exit(1) - -if __name__ == "__main__": - # Append lib and apps directories to PYTHONPATH - - - execute_manager(settings) diff --git a/cas/settings.py b/cas/settings.py deleted file mode 100644 index 38343ab..0000000 --- a/cas/settings.py +++ /dev/null @@ -1,107 +0,0 @@ -# -*- coding: utf-8 -*- -from os import path - -PROJECT_ROOT = path.realpath(path.dirname(__file__)) - -DEBUG = True -TEMPLATE_DEBUG = DEBUG - -ADMINS = [] - -MANAGERS = ADMINS - -DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. -DATABASE_NAME = PROJECT_ROOT + '/dev.sqlite' # Or path to database file if using sqlite3. -DATABASE_USER = '' # Not used with sqlite3. -DATABASE_PASSWORD = '' # Not used with sqlite3. -DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. -DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. - -# Local time zone for this installation. Choices can be found here: -# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name -# although not all choices may be available on all operating systems. -# If running in a Windows environment this must be set to the same as your -# system time zone. -TIME_ZONE = 'Europe/Warsaw' - -# Language code for this installation. All choices can be found here: -# http://www.i18nguy.com/unicode/language-identifiers.html -LANGUAGE_CODE = 'pl' - -SITE_ID = 1 - -# If you set this to False, Django will make some optimizations so as not -# to load the internationalization machinery. -USE_I18N = True - -# Absolute path to the directory that holds media. -# Example: "/home/media/media.lawrence.com/" -MEDIA_ROOT = PROJECT_ROOT + '/media/' -STATIC_ROOT = PROJECT_ROOT + '/static/' - -# URL that handles the media served from MEDIA_ROOT. Make sure to use a -# trailing slash if there is a path component (optional in other cases). -# Examples: "http://media.lawrence.com", "http://example.com/media/" -MEDIA_URL = '/media/' -STATIC_URL = '/static/' - -# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a -# trailing slash. -# Examples: "http://foo.com/media/", "/media/". -ADMIN_MEDIA_PREFIX = '/admin-media/' - -# List of callables that know how to import templates from various sources. -TEMPLATE_LOADERS = ( - 'django.template.loaders.filesystem.load_template_source', - 'django.template.loaders.app_directories.load_template_source', -# 'django.template.loaders.eggs.load_template_source', -) - -TEMPLATE_CONTEXT_PROCESSORS = ( - "django.core.context_processors.auth", - "django.core.context_processors.debug", - "django.core.context_processors.i18n", - "django.core.context_processors.request", -) - - -MIDDLEWARE_CLASSES = ( - 'django.middleware.common.CommonMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.middleware.doc.XViewMiddleware', -) - -ROOT_URLCONF = 'urls' - -TEMPLATE_DIRS = ( - PROJECT_ROOT + '/templates', -) - -INSTALLED_APPS = ( - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.sites', - 'django.contrib.admin', - 'django.contrib.admindocs', - - 'cas_provider', -) - -# django-cas-provider settings -LOGIN_URL = '/cas/login/' -LOGOUT_URL = '/cas/logout/' -CAS_CUSTOM_ATTRIBUTES_CALLBACK = 'utils.custom_attributes_callback' -SESSION_COOKIE_NAME = 'fnpcas_sessionid' - -# Python logging settings -import logging -import logging.config -logging.config.fileConfig(path.join(PROJECT_ROOT, "logging.cfg")) - -# Import localsettings file, which may override settings defined here -try: - from localsettings import * -except ImportError: - pass diff --git a/cas/templates/cas/login.html b/cas/templates/cas/login.html deleted file mode 100644 index e51cd8d..0000000 --- a/cas/templates/cas/login.html +++ /dev/null @@ -1,21 +0,0 @@ -{% extends "cas_base.html" %} - -{% block content %} -
-
- Zaloguj się - {% if errors %} -
    - {% for error in errors %} -
  • {{ error|escape }}
  • - {% endfor %} -
- {% endif %} - - {{ form.as_table }} -
-

-
-
-{% endblock %} - \ No newline at end of file diff --git a/cas/templates/cas/logout.html b/cas/templates/cas/logout.html deleted file mode 100644 index d2a4009..0000000 --- a/cas/templates/cas/logout.html +++ /dev/null @@ -1,12 +0,0 @@ -{% extends "cas_base.html" %} - -{% block title %} -Logged out -{% endblock %} - -{% block content %} -

Logged out

- -

You have successfully logged out. To ensure that you are logged out of all services, please close your browser.

- {% if url %}

Click here to return to {{ url }}

{% endif %} -{% endblock %} \ No newline at end of file diff --git a/cas/templates/cas_base.html b/cas/templates/cas_base.html deleted file mode 100644 index a49c721..0000000 --- a/cas/templates/cas_base.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - {% block title %}Fundacja Nowoczesna Polska - CAS{% block subtitle %}{% endblock subtitle %}{% endblock title%} - {% block extrahead %} - {% endblock %} - - -
{% block content %} {% endblock %}
- - diff --git a/cas/urls.py b/cas/urls.py deleted file mode 100644 index f1aeca6..0000000 --- a/cas/urls.py +++ /dev/null @@ -1,17 +0,0 @@ -# -*- coding: utf-8 -*- -from django.conf.urls.defaults import * -from django.contrib import admin -from django.conf import settings - -admin.autodiscover() - -urlpatterns = patterns('', - # Admin panel - url(r'^admin/doc/', include('django.contrib.admindocs.urls')), - url(r'^admin/(.*)', admin.site.root), - - # django-cas-provider - url(r'^', include('cas_provider.urls')), -) - - diff --git a/cas/utils.py b/cas/utils.py deleted file mode 100644 index e5bf2e3..0000000 --- a/cas/utils.py +++ /dev/null @@ -1,6 +0,0 @@ -def custom_attributes_callback(user): - return { - 'email': user.email, - 'firstname': user.first_name, - 'lastname': user.last_name, - } diff --git a/fabfile.py b/fabfile.py deleted file mode 100644 index d70c13f..0000000 --- a/fabfile.py +++ /dev/null @@ -1,159 +0,0 @@ -from __future__ import with_statement # needed for python 2.5 -from fabric.api import * -from fabric.contrib import files - -import os - - -# ========== -# = Config = -# ========== -# Globals -env.project_name = 'cas' -env.use_south = False - -# Servers -def staging(): - """Use staging server""" - env.hosts = ['stigma.nowoczesnapolska.org.pl:2222'] - env.user = 'platforma' - env.path = '/var/services/cas' - env.python = '/usr/bin/python' - env.virtualenv = '/usr/bin/virtualenv' - env.pip = '/usr/bin/pip' - -def production(): - """Use production server""" - env.hosts = ['wolnelektury.pl:22123'] - env.user = 'fundacja' - env.path = '/opt/lektury/cas' - env.python = '/opt/lektury/basevirtualenv/bin/python' - env.virtualenv = '/opt/lektury/basevirtualenv/bin/virtualenv' - env.pip = '/opt/lektury/basevirtualenv/bin/pip' - - -# ========= -# = Tasks = -# ========= -def test(): - "Run the test suite and bail out if it fails" - require('hosts', 'path', provided_by=[staging, production]) - result = run('cd %(path)s/%(project_name)s; %(python)s manage.py test' % env) - -def setup(): - """ - Setup a fresh virtualenv as well as a few useful directories, then run - a full deployment. virtualenv and pip should be already installed. - """ - require('hosts', 'path', provided_by=[staging, production]) - - run('mkdir -p %(path)s; cd %(path)s; %(virtualenv)s --no-site-packages .;' % env, pty=True) - run('cd %(path)s; mkdir releases; mkdir shared; mkdir packages;' % env, pty=True) - run('cd %(path)s/releases; ln -s . current; ln -s . previous' % env, pty=True) - deploy() - -def deploy(): - """ - Deploy the latest version of the site to the servers, - install any required third party modules, - install the virtual host and then restart the webserver - """ - require('hosts', 'path', provided_by=[staging, production]) - - import time - env.release = time.strftime('%Y-%m-%dT%H%M') - - upload_tar_from_git() - upload_wsgi_script() - # upload_vhost_sample() - install_requirements() - copy_localsettings() - symlink_current_release() - migrate() - restart_webserver() - -def deploy_version(version): - "Specify a specific version to be made live" - require('hosts', 'path', provided_by=[localhost,webserver]) - env.version = version - with cd(env.path): - run('rm releases/previous; mv releases/current releases/previous;', pty=True) - run('ln -s %(version)s releases/current' % env, pty=True) - restart_webserver() - -def rollback(): - """ - Limited rollback capability. Simple loads the previously current - version of the code. Rolling back again will swap between the two. - """ - require('hosts', provided_by=[staging, production]) - require('path') - with cd(env.path): - run('mv releases/current releases/_previous;', pty=True) - run('mv releases/previous releases/current;', pty=True) - run('mv releases/_previous releases/previous;', pty=True) - restart_webserver() - - -# ===================================================================== -# = Helpers. These are called by other functions rather than directly = -# ===================================================================== -def upload_tar_from_git(): - "Create an archive from the current Git master branch and upload it" - print '>>> upload tar from git' - require('release', provided_by=[deploy]) - local('git archive --format=tar master | gzip > %(release)s.tar.gz' % env) - run('mkdir -p %(path)s/releases/%(release)s' % env, pty=True) - run('mkdir -p %(path)s/packages' % env, pty=True) - put('%(release)s.tar.gz' % env, '%(path)s/packages/' % env) - run('cd %(path)s/releases/%(release)s && tar zxf ../../packages/%(release)s.tar.gz' % env, pty=True) - local('rm %(release)s.tar.gz' % env) - -def upload_vhost_sample(): - "Create and upload Apache virtual host configuration sample" - print ">>> upload vhost sample" - files.upload_template('%(project_name)s.vhost.template' % env, '%(path)s/%(project_name)s.vhost.sample' % env, context=env) - -def upload_wsgi_script(): - "Create and upload a wsgi script sample" - print ">>> upload wsgi script sample" - files.upload_template('%(project_name)s.wsgi.template' % env, '%(path)s/%(project_name)s.wsgi' % env, context=env) - run('chmod ug+x %(path)s/%(project_name)s.wsgi' % env) - -def install_requirements(): - "Install the required packages from the requirements file using pip" - print '>>> install requirements' - require('release', provided_by=[deploy]) - run('cd %(path)s; %(pip)s install -E . -r %(path)s/releases/%(release)s/requirements.txt' % env, pty=True) - -def copy_localsettings(): - "Copy localsettings.py from root directory to release directory (if this file exists)" - print ">>> copy localsettings" - require('release', provided_by=[deploy]) - require('path', provided_by=[staging, production]) - - with settings(warn_only=True): - run('cp %(path)s/localsettings.py %(path)s/releases/%(release)s/%(project_name)s' % env) - -def symlink_current_release(): - "Symlink our current release" - print '>>> symlink current release' - require('release', provided_by=[deploy]) - require('path', provided_by=[staging, production]) - with cd(env.path): - run('rm releases/previous; mv releases/current releases/previous') - run('ln -s %(release)s releases/current' % env) - -def migrate(): - "Update the database" - print '>>> migrate' - require('project_name', provided_by=[staging, production]) - with cd('%(path)s/releases/current/%(project_name)s' % env): - run('../../../bin/python manage.py syncdb --noinput' % env, pty=True) - if env.use_south: - run('../../../bin/python manage.py migrate' % env, pty=True) - -def restart_webserver(): - "Restart the web server" - print '>>> restart webserver' - run('touch %(path)s/releases/current/%(project_name)s/%(project_name)s.wsgi' % env) diff --git a/src/cas/__init__.py b/src/cas/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/cas/logging.cfg b/src/cas/logging.cfg new file mode 100644 index 0000000..ce758bc --- /dev/null +++ b/src/cas/logging.cfg @@ -0,0 +1,34 @@ +[loggers] +keys=root,fnp + +[handlers] +keys=console,lf + +[formatters] +keys=default + +[logger_root] +level=DEBUG +handlers=console + +[logger_fnp] +level=DEBUG +handlers=lf,console +qualname=fnp +propagate=0 + +[formatter_default] +format=%(asctime)s %(name)s/%(levelname)s :: %(module)s:%(lineno)d :: %(message)s +datefmt= + +[handler_console] +class=StreamHandler +level=DEBUG +formatter=default +args=(sys.stderr, ) + +[handler_lf] +class=FileHandler +level=DEBUG +formatter=default +args=("/var/services/logs/cas.log",) \ No newline at end of file diff --git a/src/cas/manage.py b/src/cas/manage.py new file mode 100644 index 0000000..741587d --- /dev/null +++ b/src/cas/manage.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python +from django.core.management import execute_manager + +from os import path +import sys + +PROJECT_ROOT = path.realpath(path.dirname(__file__)) +sys.path.insert(0, path.abspath(path.join(PROJECT_ROOT, "..", "provider"))) +print sys.path + +try: + import settings # Assumed to be in the same directory. +except ImportError: + import traceback + traceback.print_exc(file =sys.stderr) + sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__) + sys.exit(1) + +if __name__ == "__main__": + # Append lib and apps directories to PYTHONPATH + + + execute_manager(settings) diff --git a/src/cas/settings.py b/src/cas/settings.py new file mode 100644 index 0000000..a039d14 --- /dev/null +++ b/src/cas/settings.py @@ -0,0 +1,107 @@ +# -*- coding: utf-8 -*- +from os import path + +PROJECT_ROOT = path.realpath(path.dirname(__file__)) + +DEBUG = True +TEMPLATE_DEBUG = DEBUG + +ADMINS = [] + +MANAGERS = ADMINS + +DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. +DATABASE_NAME = PROJECT_ROOT + '/dev.sqlite' # Or path to database file if using sqlite3. +DATABASE_USER = '' # Not used with sqlite3. +DATABASE_PASSWORD = '' # Not used with sqlite3. +DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. +DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. + +# Local time zone for this installation. Choices can be found here: +# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name +# although not all choices may be available on all operating systems. +# If running in a Windows environment this must be set to the same as your +# system time zone. +TIME_ZONE = 'Europe/Warsaw Poland' + +# Language code for this installation. All choices can be found here: +# http://www.i18nguy.com/unicode/language-identifiers.html +LANGUAGE_CODE = 'pl' + +SITE_ID = 1 + +# If you set this to False, Django will make some optimizations so as not +# to load the internationalization machinery. +USE_I18N = True + +# Absolute path to the directory that holds media. +# Example: "/home/media/media.lawrence.com/" +MEDIA_ROOT = PROJECT_ROOT + '/media/' +STATIC_ROOT = PROJECT_ROOT + '/static/' + +# URL that handles the media served from MEDIA_ROOT. Make sure to use a +# trailing slash if there is a path component (optional in other cases). +# Examples: "http://media.lawrence.com", "http://example.com/media/" +MEDIA_URL = '/media/' +STATIC_URL = '/static/' + +# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a +# trailing slash. +# Examples: "http://foo.com/media/", "/media/". +ADMIN_MEDIA_PREFIX = '/admin-media/' + +# List of callables that know how to import templates from various sources. +TEMPLATE_LOADERS = ( + 'django.template.loaders.filesystem.load_template_source', + 'django.template.loaders.app_directories.load_template_source', +# 'django.template.loaders.eggs.load_template_source', +) + +TEMPLATE_CONTEXT_PROCESSORS = ( + "django.core.context_processors.auth", + "django.core.context_processors.debug", + "django.core.context_processors.i18n", + "django.core.context_processors.request", +) + + +MIDDLEWARE_CLASSES = ( + 'django.middleware.common.CommonMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.middleware.doc.XViewMiddleware', +) + +ROOT_URLCONF = 'urls' + +TEMPLATE_DIRS = ( + PROJECT_ROOT + '/templates', +) + +INSTALLED_APPS = ( + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.sites', + 'django.contrib.admin', + 'django.contrib.admindocs', + + 'cas_provider', +) + +# django-cas-provider settings +LOGIN_URL = '/cas/login/' +LOGOUT_URL = '/cas/logout/' +CAS_CUSTOM_ATTRIBUTES_CALLBACK = 'utils.custom_attributes_callback' +SESSION_COOKIE_NAME = 'fnpcas' + +# Python logging settings +import logging +import logging.config +logging.config.fileConfig(path.join(PROJECT_ROOT, "logging.cfg")) + +# Import localsettings file, which may override settings defined here +try: + from localsettings import * +except ImportError: + pass diff --git a/src/cas/templates/cas/login.html b/src/cas/templates/cas/login.html new file mode 100644 index 0000000..e51cd8d --- /dev/null +++ b/src/cas/templates/cas/login.html @@ -0,0 +1,21 @@ +{% extends "cas_base.html" %} + +{% block content %} +
+
+ Zaloguj się + {% if errors %} +
    + {% for error in errors %} +
  • {{ error|escape }}
  • + {% endfor %} +
+ {% endif %} + + {{ form.as_table }} +
+

+
+
+{% endblock %} + \ No newline at end of file diff --git a/src/cas/templates/cas/logout.html b/src/cas/templates/cas/logout.html new file mode 100644 index 0000000..d2a4009 --- /dev/null +++ b/src/cas/templates/cas/logout.html @@ -0,0 +1,12 @@ +{% extends "cas_base.html" %} + +{% block title %} +Logged out +{% endblock %} + +{% block content %} +

Logged out

+ +

You have successfully logged out. To ensure that you are logged out of all services, please close your browser.

+ {% if url %}

Click here to return to {{ url }}

{% endif %} +{% endblock %} \ No newline at end of file diff --git a/src/cas/templates/cas_base.html b/src/cas/templates/cas_base.html new file mode 100644 index 0000000..a49c721 --- /dev/null +++ b/src/cas/templates/cas_base.html @@ -0,0 +1,13 @@ + + + + + {% block title %}Fundacja Nowoczesna Polska - CAS{% block subtitle %}{% endblock subtitle %}{% endblock title%} + {% block extrahead %} + {% endblock %} + + +
{% block content %} {% endblock %}
+ + diff --git a/src/cas/urls.py b/src/cas/urls.py new file mode 100644 index 0000000..f1aeca6 --- /dev/null +++ b/src/cas/urls.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- +from django.conf.urls.defaults import * +from django.contrib import admin +from django.conf import settings + +admin.autodiscover() + +urlpatterns = patterns('', + # Admin panel + url(r'^admin/doc/', include('django.contrib.admindocs.urls')), + url(r'^admin/(.*)', admin.site.root), + + # django-cas-provider + url(r'^', include('cas_provider.urls')), +) + + diff --git a/src/cas/utils.py b/src/cas/utils.py new file mode 100644 index 0000000..e5bf2e3 --- /dev/null +++ b/src/cas/utils.py @@ -0,0 +1,6 @@ +def custom_attributes_callback(user): + return { + 'email': user.email, + 'firstname': user.first_name, + 'lastname': user.last_name, + }