From ffcc8e2726a0d3aaf82e1262cc10896268202f1b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Barrois?= Date: Sat, 6 Apr 2013 00:34:19 +0200 Subject: [PATCH] Finish setup. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Raphaël Barrois --- README.xorg | 11 +++++ bin/xorg-sentry | 18 ++++++++ etc/sentry.initd | 64 ++++++++++++++++++++++++++++ requirements.txt | 1 + xorg_sentry/__init__.py | 0 xorg_sentry/conf.py | 24 ++++++++--- xorg_sentry/models.py | 0 xorg_sentry/templates/xorg_sentry/login.html | 18 ++++++++ xorg_sentry/urls.py | 9 ++++ xorg_sentry/views.py | 8 ++++ 10 files changed, 148 insertions(+), 5 deletions(-) create mode 100755 bin/xorg-sentry create mode 100755 etc/sentry.initd create mode 100644 xorg_sentry/__init__.py create mode 100644 xorg_sentry/models.py create mode 100644 xorg_sentry/templates/xorg_sentry/login.html create mode 100644 xorg_sentry/urls.py create mode 100644 xorg_sentry/views.py diff --git a/README.xorg b/README.xorg index fc38fdf..51abeb4 100644 --- a/README.xorg +++ b/README.xorg @@ -12,6 +12,17 @@ Since modern development hipsters don't bother providing proper packages for Deb - It contains all dependencies - The X.org setup lives in ``xorg_sentry/`` +Dependencies +------------ + +Dependencies are listed in the ``requirements.txt`` file. +Install them with:: + + pip install -r requirements.txt + +Under Debian, you should use the following packages: +- python-dev + .. _Sentry: http://sentry.readthedocs.org/ diff --git a/bin/xorg-sentry b/bin/xorg-sentry new file mode 100755 index 0000000..e333e6e --- /dev/null +++ b/bin/xorg-sentry @@ -0,0 +1,18 @@ +#!/usr/bin/env python + +import os.path +import site +import sys + +root = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) +config = os.path.join(root, 'xorg_sentry', 'conf.py') + +site.addsitedir(os.path.join(root, 'venv', 'lib', 'python2.6', 'site-packages')) +sys.path.insert(0, root) + +from sentry.utils import runner + +sys.argv.insert(1, "--config=%s" % config) + +runner.main() + diff --git a/etc/sentry.initd b/etc/sentry.initd new file mode 100755 index 0000000..83781ea --- /dev/null +++ b/etc/sentry.initd @@ -0,0 +1,64 @@ +#!/bin/sh + +### BEGIN INIT INFO +# Provides: xorg-sentry +# Required-Start: $local_fs $remote_fs $network $syslog +# Required-Stop: $local_fs $remote_fs $network $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: starts the xorg-sentry server +# Description: starts xorg-sentry using start-stop-daemon +### END INIT INFO + +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +DAEMON=/home/web/sentry/bin/xorg-sentry +NAME=xorg-sentry +DESC=xorg-sentry +USER=web + +# Include xorg-sentry defaults if available +if [ -f /etc/default/xorg-sentry ]; then + . /etc/default/xorg-sentry +fi + +test -x $DAEMON || exit 0 + +set -e + +. /lib/lsb/init-functions + +case "$1" in + start) + echo -n "Starting $DESC: " + start-stop-daemon --start --chuid $USER --quiet --pidfile /var/run/$NAME.pid \ + --background --exec $DAEMON -- start $DAEMON_OPTS || true + echo "$NAME." + ;; + + stop) + echo -n "Stopping $DESC: " + start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \ + --exec $DAEMON || true + echo "$NAME." + ;; + + restart|force-reload) + echo -n "Restarting $DESC: " + start-stop-daemon --stop --quiet --pidfile \ + /var/run/$NAME.pid --exec $DAEMON || true + sleep 1 + start-stop-daemon --start --chuid $USER --quiet --pidfile \ + /var/run/$NAME.pid --background --exec $DAEMON -- $DAEMON_OPTS || true + echo "$NAME." + ;; + + status) + status_of_proc -p /var/run/$NAME.pid "$DAEMON" xorg-sentry && exit 0 || exit $? + ;; + *) + echo "Usage: $NAME {start|stop|restart|force-reload|status}" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/requirements.txt b/requirements.txt index ae2c7bc..a3a5fba 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ sentry +django_authgroupex diff --git a/xorg_sentry/__init__.py b/xorg_sentry/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/xorg_sentry/conf.py b/xorg_sentry/conf.py index 368a87d..28a6691 100644 --- a/xorg_sentry/conf.py +++ b/xorg_sentry/conf.py @@ -9,10 +9,6 @@ from sentry.conf.server import * EXCLUDED_APPS = ('djcelery', 'kombu.transport.django', 'social_auth', 'django_social_auth_trello') INSTALLED_APPS = tuple(app for app in INSTALLED_APPS if app not in EXCLUDED_APPS) -AUTHENTICATION_BACKENDS = ( - 'sentry.utils.auth.EmailAuthBackend', -) - TEMPLATE_CONTEXT_PROCESSORS = tuple( tcp for tcp in TEMPLATE_CONTEXT_PROCESSORS if 'social_auth' not in tcp) @@ -26,12 +22,17 @@ CONF_ROOT = os.path.dirname(__file__) def get_password(filename): with open(os.path.join(CONF_ROOT, 'private', filename)) as f: - return f.readline() + return f.readline().strip() # Actual configuration # ==================== +AUTHENTICATION_BACKENDS = ( + #'sentry.utils.auth.EmailAuthBackend', + 'django_authgroupex.auth.AuthGroupeXBackend', +) + DATABASES = { 'default': { # You can swap out the engine for MySQL easily by changing this value @@ -46,6 +47,13 @@ DATABASES = { } } +INSTALLED_APPS = ( + 'django_authgroupex', + 'xorg_sentry', +) + INSTALLED_APPS + +ROOT_URLCONF = 'xorg_sentry.urls' + SENTRY_KEY = get_password('secret_key') # Set this to false to require authentication @@ -76,3 +84,9 @@ EMAIL_HOST_USER = '' EMAIL_PORT = 25 EMAIL_USE_TLS = False + +AUTHGROUPEX_KEY = get_password('authgroupex_key') +AUTHGROUPEX_SUPERADMIN_PERMS = ('admin',) +AUTHGROUPEX_STAFF_PERMS = ('admin',) +AUTHGROUPEX_RETURN_URL = 'https://errors.polytechnique.org/xorgauth/' +AUTHGROUPEX_FIELDS = ('username', 'firstname', 'lastname', 'perms') diff --git a/xorg_sentry/models.py b/xorg_sentry/models.py new file mode 100644 index 0000000..e69de29 diff --git a/xorg_sentry/templates/xorg_sentry/login.html b/xorg_sentry/templates/xorg_sentry/login.html new file mode 100644 index 0000000..7280037 --- /dev/null +++ b/xorg_sentry/templates/xorg_sentry/login.html @@ -0,0 +1,18 @@ +{% extends "sentry/layout.html" %} +{% load i18n %} +{% load url from future %} +{% block title %}{% trans "Login" %} | {{ block.super }}{% endblock %} + +{% block main %} +
+ {% if next %} +

{% trans "Please login to continue." %}

+ {% endif %} + + +
+{% endblock %} diff --git a/xorg_sentry/urls.py b/xorg_sentry/urls.py new file mode 100644 index 0000000..d906e2d --- /dev/null +++ b/xorg_sentry/urls.py @@ -0,0 +1,9 @@ +from django.conf.urls.defaults import patterns, url, include +from sentry.conf.urls import handler404, handler500 +from sentry.conf.urls import urlpatterns as sentry_urlpatterns + + +urlpatterns = patterns('', + url(r'^xorgauth/', include('django_authgroupex.urls', namespace='authgroupex')), + url(r'^login/', 'xorg_sentry.views.login', name='xlogin'), +) + sentry_urlpatterns diff --git a/xorg_sentry/views.py b/xorg_sentry/views.py new file mode 100644 index 0000000..d87a92e --- /dev/null +++ b/xorg_sentry/views.py @@ -0,0 +1,8 @@ + +from django.shortcuts import render +from django.views.decorators.cache import never_cache +from sentry.web.helpers import render_to_response + +@never_cache +def login(request): + return render(request, 'xorg_sentry/login.html') -- 2.1.4