This repository was archived by the owner on Jan 25, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +25
-1
lines changed
Expand file tree Collapse file tree 4 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,10 @@ There are two things you need to do in ``settings.py``
6969 ``AUTOCREATE_VALID_SSL_USERS = True ``. Auto-created users will be set to
7070 inactive by default, consider using the `User.is_active `_ field in your
7171 `LOGIN_REDIRECT_URL `_ view to notifying the user of their status.
72+ 3. If you want to use the standard login url, set `SSLCLIENT_LOGIN_URL = None ` or leave it undefined.
73+ For cases where you want a seperate login URL for SSL auth, set `SSLCLIENT_LOGIN_URL = "/YOUR_URL/" `.
74+ `SSLCLIENT_LOGIN_URL ` is designed for use cases where some users login via the regular Django login
75+ without using SSLCLIENT auth, but you have a seperate login URL for users that login with SSLCLIENT auth.
7276
7377For details, see ``testapp/ssltest/settings.py ``
7478
Original file line number Diff line number Diff line change @@ -101,7 +101,8 @@ def process_request(self, request):
101101 return
102102 logger .debug ("REST API call, not logging user in" )
103103 request .user = user
104- elif request .path_info == settings .LOGIN_URL :
104+ elif request .path_info == settings .LOGIN_URL or \
105+ (hasattr (settings , 'SSLCLIENT_LOGIN_URL' ) and request .path_info == settings .SSLCLIENT_LOGIN_URL ):
105106 user = authenticate (request = request )
106107 if user is None or not check_user_auth (user ):
107108 return
Original file line number Diff line number Diff line change 3636SILENCED_SYSTEM_CHECKS = (
3737 '1_10.W001' ,
3838)
39+
40+ SSLCLIENT_LOGIN_URL = None
Original file line number Diff line number Diff line change @@ -21,3 +21,20 @@ def test_login_new_user(self):
2121 self .assertEqual (user .username , '42' )
2222 self .assertEqual (user .first_name , 'John' )
2323 self .assertEqual (user .last_name , 'Smith' )
24+
25+ def test_login_new_user_sslurl (self ):
26+ """Ensure users are automatically created."""
27+ # Simulate an SSL connection (of a new user)
28+ with self .settings (SSLCLIENT_LOGIN_URL = "/pivlogin" ):
29+ self .client .get (
30+ settings .SSLCLIENT_LOGIN_URL ,
31+ HTTP_X_SSL_AUTHENTICATED = 'SUCCESS' ,
32+ HTTP_X_SSL_USER_DN = 'C=FI/serialNumber=42/GN=John/SN=Smith/CN=John Smith' ,
33+ HTTP_X_FORWARDED_PROTOCOL = 'https'
34+ )
35+
36+ # Ensure the new user was created
37+ user = User .objects .last ()
38+ self .assertEqual (user .username , '42' )
39+ self .assertEqual (user .first_name , 'John' )
40+ self .assertEqual (user .last_name , 'Smith' )
You can’t perform that action at this time.
0 commit comments