Finish setup. master
authorRaphaël Barrois <raphael.barrois@polytechnique.org>
Fri, 5 Apr 2013 22:34:19 +0000 (00:34 +0200)
committerRaphaël Barrois <raphael.barrois@polytechnique.org>
Fri, 5 Apr 2013 22:34:19 +0000 (00:34 +0200)
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
README.xorg
bin/xorg-sentry [new file with mode: 0755]
etc/sentry.initd [new file with mode: 0755]
requirements.txt
xorg_sentry/__init__.py [new file with mode: 0644]
xorg_sentry/conf.py
xorg_sentry/models.py [new file with mode: 0644]
xorg_sentry/templates/xorg_sentry/login.html [new file with mode: 0644]
xorg_sentry/urls.py [new file with mode: 0644]
xorg_sentry/views.py [new file with mode: 0644]

index fc38fdf..51abeb4 100644 (file)
@@ -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 (executable)
index 0000000..e333e6e
--- /dev/null
@@ -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 (executable)
index 0000000..83781ea
--- /dev/null
@@ -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
index ae2c7bc..a3a5fba 100644 (file)
@@ -1 +1,2 @@
 sentry
+django_authgroupex
diff --git a/xorg_sentry/__init__.py b/xorg_sentry/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
index 368a87d..28a6691 100644 (file)
@@ -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 (file)
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 (file)
index 0000000..7280037
--- /dev/null
@@ -0,0 +1,18 @@
+{% extends "sentry/layout.html" %}
+{% load i18n %}
+{% load url from future %}
+{% block title %}{% trans "Login" %} | {{ block.super }}{% endblock %}
+
+{% block main %}
+    <section class="body">
+       {% if next %}
+            <p class="alert alert-info">{% trans "Please login to continue." %}</p>
+        {% endif %}
+
+        <div class="row">
+            <div class="span6">
+                <a class="btn btn-primary" href="{% url 'authgroupex:login' %}">Connexion via X.org</a>
+            </div>
+        </div>
+    </section>
+{% endblock %}
diff --git a/xorg_sentry/urls.py b/xorg_sentry/urls.py
new file mode 100644 (file)
index 0000000..d906e2d
--- /dev/null
@@ -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 (file)
index 0000000..d87a92e
--- /dev/null
@@ -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')