read ssl data from http headers

This commit is contained in:
Serghei Mihai 2015-05-20 15:42:53 +02:00
parent b97660b491
commit 92d962b9ae
2 changed files with 14 additions and 3 deletions

View File

@ -1,6 +1,16 @@
from authentic2.auth2_auth.auth2_ssl.util import SSLInfo as BaseSSLInfo
from . import app_settings
class SSLInfo(BaseSSLInfo):
def __init__(self, request):
ssl_headers = [(k[5:], v) for k, v in request.META.iteritems() if k.startswith('HTTP_SS')]
self.read_env(dict(ssl_headers))
def get_x509_url(request):
return 'https://%s:%s' % (request.get_host(),
app_settings.AUTH_PORT)

View File

@ -6,16 +6,17 @@ from django.template import RequestContext
from django.contrib.auth import authenticate, login
from django.contrib import messages
from authentic2.auth2_auth.auth2_ssl import models, util
from authentic2.auth2_auth.auth2_ssl import models
from authentic2.utils import continue_to_next_url, redirect, redirect_to_login
from .backends import BeIDBackend
from .util import SSLInfo
logger = logging.getLogger(__name__)
def handle_authentication(request, *args, **kwargs):
ssl_info = util.SSLInfo(request)
ssl_info = SSLInfo(request)
logger.debug('received SSL info: %s', ssl_info)
if not request.user.is_authenticated():
user = authenticate(ssl_info=ssl_info)
@ -33,7 +34,7 @@ def handle_authentication(request, *args, **kwargs):
def add_beid(request):
if request.user.is_authenticated:
ssl_info = util.SSLInfo(request)
ssl_info = SSLInfo(request)
if BeIDBackend().link_user(ssl_info, request.user):
logger.info('Successful linking of the SSL '
'certificate to an account')