context processor computing beid url

compute x509 auth url
This commit is contained in:
Serghei Mihai 2015-05-19 15:33:51 +02:00
parent be21f87044
commit b97660b491
5 changed files with 38 additions and 8 deletions

View File

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
import sys
class AppSettings(object):
__DEFAULTS = dict(
AUTH_PORT=8443,
)
def __init__(self, prefix):
self.prefix = prefix
def _setting(self, name, dflt):
from django.conf import settings
return getattr(settings, self.prefix+name, dflt)
def __getattr__(self, name):
if name not in self.__DEFAULTS:
raise AttributeError(name)
return self._setting(name, self.__DEFAULTS[name])
app_settings = AppSettings('BEID_')
app_settings.__name__ = __name__
app_settings.__file__ = __file__
sys.modules[__name__] = app_settings

View File

@ -0,0 +1,4 @@
from .util import get_x509_url
def beid_processor(request):
return {'beid_url': get_x509_url(request)}

View File

@ -7,13 +7,7 @@
<p>
{% trans "Please connect the card reader and put your identity card in" %}
</p>
<form method="post" action="">
{% csrf_token %}
{{ form.as_p }}
<form id='beid_login' action='{{ beid_url }}{% url "beid_signin" %}'>
<input type="submit" name="{{ submit_name }}" value="{% trans "Log in" %}"/>
{% if cancel %}
<input type="submit" name="cancel" value="{% trans 'Cancel' %}"/>
{% endif %}
</form>
</div>

View File

@ -24,7 +24,7 @@
{% endfor %}
</ul>
<p>
<form action="{% url "add_beid" %}" method="get">
<form action="{{ beid_url }}{% url "add_beid" %}" method="get">
<label for="id_del_cert">{% trans "Have a belgian eID card?" %}</label>
<input type="hidden" name="next" value="{% url "account_management" %}#a2-beid-certificate-profile" />
<input type="submit" class="submit-button a2-ssl-certificate-submit-button" value="{% trans "Link it to your account" %}">

View File

@ -0,0 +1,6 @@
from . import app_settings
def get_x509_url(request):
return 'https://%s:%s' % (request.get_host(),
app_settings.AUTH_PORT)