code: def get_remote_user(request):
      
      if 'HTTP_AUTHORIZATION' not in request.environ:
          return
      authorization = request.environ['HTTP_AUTHORIZATION']
      try:
          authmeth, auth = authorization.split(' ', 1)
      except ValueError:  # not enough values to unpack
          return
      if authmeth.lower() != 'basic':
          return
      try:
          auth = base64.b64decode(auth.strip().encode('latin1')).decode('latin1')
      except (binascii.Error, TypeError):  # can't decode
          return
      try:
          login, password = auth.split(':', 1)
      except ValueError:  # not enough values to unpack
          return
      return login, password
docs: Parse basic HTTP_AUTHORIZATION and return user name