SSL authenticating middleware

This commit is contained in:
Serghei Mihai 2015-05-20 16:09:03 +02:00
parent 6cbbb4b567
commit 4bfd2f887c
2 changed files with 18 additions and 1 deletions

View File

@ -17,7 +17,7 @@ class Plugin(object):
return ('authentic2_beid.frontends.BeIDFrontend',)
def get_after_middleware(self):
return ('authentic2.auth2_auth.auth2_ssl.middleware.SSLAuthMiddleware',)
return ('authentic2_beid.middleware.SSLAuthMiddleware',)
def get_apps(self):
return ('authentic2.auth2_auth.auth2_ssl',

View File

@ -0,0 +1,17 @@
from django.contrib.auth import authenticate, login
from . import util, app_settings
class SSLAuthMiddleware(object):
"""
attemps to login user based in client certificate info
"""
def process_request(self, request):
if request.user.is_authenticated():
return
ssl_info = util.SSLInfo(request)
user = authenticate(ssl_info=ssl_info)
if user and request.user != user:
login(request, user)