1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: Apache-2.0
8 from . import auth_event
10 def pam_sm_authenticate(pamh, flags, argv):
12 config['arvados_api_host'] = argv[1]
13 config['virtual_machine_hostname'] = argv[2]
19 username = pamh.get_user(None)
20 except pamh.exception as e:
24 return pamh.PAM_USER_UNKNOWN
27 prompt = '' if config.get('noprompt') else 'Arvados API token: '
28 token = pamh.conversation(pamh.Message(pamh.PAM_PROMPT_ECHO_OFF, prompt)).resp
29 except pamh.exception as e:
32 if auth_event.AuthEvent(
35 client_host=pamh.rhost,
37 token=token).can_login():
38 return pamh.PAM_SUCCESS
40 return pamh.PAM_AUTH_ERR
42 def pam_sm_setcred(pamh, flags, argv):
43 return pamh.PAM_SUCCESS
45 def pam_sm_acct_mgmt(pamh, flags, argv):
46 return pamh.PAM_SUCCESS
48 def pam_sm_open_session(pamh, flags, argv):
49 return pamh.PAM_SUCCESS
51 def pam_sm_close_session(pamh, flags, argv):
52 return pamh.PAM_SUCCESS
54 def pam_sm_chauthtok(pamh, flags, argv):
55 return pamh.PAM_SUCCESS