• 
      

    Avoid re-authenticating x509 users unless necessary

    Review Request #10402 — Created Feb. 11, 2019 and updated

    Information

    Review Board
    master
    c4a5d7e...

    Reviewers

    Avoid re-authenticating x509 users unless necessary

    N/A. I haven't ran the tests.

    Description From Last Updated

    This change breaks the unit tests: ====================================================================== ERROR: Testing X509AuthMiddleware.process_request with backend enabled and username environment variable present ---------------------------------------------------------------------- Traceback …

    daviddavid

    W503 line break before binary operator

    reviewbotreviewbot
    Checks run (1 failed, 1 succeeded)
    flake8 failed.
    JSHint passed.

    flake8

    jcannon
    1. 
        
    2. If I find more time I can fully set up the dev environment and run the tests, but for now this should put you guys on the right path for improving X509 authentication. Feel free to steal the implementation. (Unfortunately it isn't 1:1 applicable to 2.5.x since it affects different files. If y'all would like a similar review for 2.5.x I can do that).

      Cheers 🍻

    3. 
        
    jcannon
    Review request changed
    Change Summary:

    Fix W503

    Commit:
    86f56f50b8af3880a71aaacbb2bf2ae51182278b
    c4a5d7ec984c9fb6528c82be3d5ded7ed69b5076

    Checks run (2 succeeded)

    flake8 passed.
    JSHint passed.
    david
    1. 
        
    2. Show all issues

      This change breaks the unit tests:

      ======================================================================
      ERROR: Testing X509AuthMiddleware.process_request with backend enabled and username environment variable present
      ----------------------------------------------------------------------
      Traceback (most recent call last):
        File "/Users/david/src/reviewboard/release-3.0.x/reviewboard/accounts/tests/test_x509_auth_middleware.py", line 63, in test_process_request_with_enabled_and_username
          result = self.middleware.process_request(self.request)
        File "/Users/david/src/reviewboard/release-3.0.x/reviewboard/accounts/middleware.py", line 114, in process_request
          clean_username = self.clean_username(x509_field, request)
        File "/Users/david/src/reviewboard/release-3.0.x/reviewboard/accounts/middleware.py", line 74, in clean_username
          backend_str = request.session[auth.BACKEND_SESSION_KEY]
        File "/Users/david/src/env/reviewboard-3.0/lib/python2.7/site-packages/django/contrib/sessions/backends/base.py", line 47, in __getitem__
          return self._session[key]
      KeyError: '_auth_user_backend'
      
    3.