Skip to content

Commit d0da74e

Browse files
committed
Support for multi-factor authentication
On systems with multi factor authentication (password and one-time token for example), PAM will ask all the factors in the conversation. Don't duplicate the password, leave the other factors empty instead because OTP systems usually accept the token being appended to the password. Example PAM dialogue on MFA systems: ``` First Factor: Second Factor: ``` Without this patch, the provided password would be submitted in both fields, which causes the login process to fail. Signed-off-by: Aurélien Bompard <aurelien@bompard.org>
1 parent 8df454c commit d0da74e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pam.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ def authenticate(self, username, password, service='login', encoding='utf-8', re
7575

7676
def conv(pam_self, query_list, user_data):
7777
response = []
78-
for prompt, msg in query_list:
79-
if msg == PAM.PAM_PROMPT_ECHO_OFF:
78+
for index, query in enumerate(query_list):
79+
prompt, msg = query
80+
if msg == PAM.PAM_PROMPT_ECHO_OFF and index == 0:
8081
response.append((password, PAM.PAM_SUCCESS))
8182
else:
8283
response.append((b'', PAM.PAM_SUCCESS))

0 commit comments

Comments
 (0)