SSL authenticating middleware
This commit is contained in:
parent
6cbbb4b567
commit
4bfd2f887c
|
@ -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',
|
||||
|
|
|
@ -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)
|
Reference in New Issue