rug-website
Go to file
H.T. Kruitbosch 20ea3b7be9 settings working 2017-11-28 14:54:58 +01:00
rugwebsite settings working 2017-11-28 14:54:58 +01:00
.gitignore first commit 2017-11-14 09:51:57 +01:00
MANIFEST.in rug huistijl werkend met COSMO 2017-11-15 14:59:24 +01:00
README.md settings working 2017-11-28 14:54:58 +01:00
manage.py first commit 2017-11-14 09:51:57 +01:00
setup.py comma 2017-11-28 14:27:32 +01:00

README.md

RUG website template and single signon for django

Template and for creating a website in the University of Groningen style, which also helps you to get single sign-on to work.

Getting started

Dependencies

Make sure these packages are installed on the webhost serving your website.

  • centos yum install libxml2-devel libxslt-devel python34-devel xmlsec1-devel libmcrypt libmcrypt-devel xmlsec1-openssl
  • ubuntu sudo apt-get install libxml2-dev libxslt1-dev libxmlsec1-dev python3-dev

Virtualenv

I would suggest you use a virtualenv, this is a directory which contains the python executables and all python packages, like django, python3-saml, etc.

mkdir rugwebsite && cd rugwebsite
virtualenv --python=/usr/bin/python3.5 venv
source venv/bin/activate
pip3 install git+ssh://git@git.webhosting.rug.nl:222/p253591/rug-website.git

Settings and X509 certificate

Create a file rugwebsite/settings.py, with settings like these:

import os

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = '....'
DEBUG = True
LOGIN_REDIRECT_URL = '/'

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'bootstrap4',
    'rugwebsite',
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.security.SecurityMiddleware',
)

ROOT_URLCONF = 'urls'

TEMPLATES = [
    {
	'BACKEND': 'django.template.backends.django.DjangoTemplates',
	'DIRS': [],
	'APP_DIRS': True,
	'OPTIONS': {
	    'context_processors': [
	        'django.template.context_processors.debug',
	        'django.template.context_processors.request',
	        'django.contrib.auth.context_processors.auth',
	        'django.contrib.messages.context_processors.messages',
	    ],
	},
    },
]

DATABASES = {
    'default': {
	'ENGINE': 'django.db.backends.sqlite3',
	'NAME': os.path.join(BASE_DIR, '..', 'db.sqlite3'),
    }
}

LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'Europe/Amsterdam'
USE_I18N = True
USE_L10N = True
USE_TZ = True

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')

SAML_ROUTE = 'sso/saml/'
SAML_REDIRECT = '/'
SAML_USERS_MAP = []

SAML_PROVIDERS = []

Make sure to fill in something random for SECRET_KEY, consult the dango documentation to make sure you're super secure.

Then you can use django-admin to complete the settings with SAML2 metadata, inclusing a private key and x509 certificate. Run the following and append the output to rugwebsite/settings.py

PYTHONPATH=. DJANGO_SETTINGS_MODULE=settings django-admin init-saml2-settings --country NL --city Groningen --organisation 'University of Groningen' --organisation-unit 'Research and Innovation Support' --common-name 'cosmo.service.rug.nl/rugwebsite' --state Groningen --support-name 'Research and Innovation Support' --support-email 'ris@list.rug.nl' --technical-name 'Research and Innovation Support' --technical-email 'ris@list.rug.nl' --base-url 'cosmo.service.rug.nl' --entity-id 'www.rug.nl/cosmo'

You can change these settings if you like.