This repository has been archived on 2023-02-21. You can view files and clone it, but cannot push or open issues or pull requests.
authentic2-beid/src/authentic2_beid/middleware.py

18 lines
464 B
Python

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)