84 def authenticate(self, configurationAttributes, requestParameters, step):
85 duo_host = configurationAttributes.get(
"duo_host").getValue2()
87 authenticationService = CdiUtil.bean(AuthenticationService)
89 identity = CdiUtil.bean(Identity)
92 print "Duo. Authenticate for step 1" 95 user = authenticationService.getAuthenticatedUser()
97 credentials = identity.getCredentials()
98 user_name = credentials.getUsername()
99 user_password = credentials.getPassword()
102 if (StringHelper.isNotEmptyString(user_name)
and StringHelper.isNotEmptyString(user_password)):
103 userService = CdiUtil.bean(UserService)
104 logged_in = authenticationService.authenticate(user_name, user_password)
109 user = authenticationService.getAuthenticatedUser()
111 if (self.use_duo_group):
112 print "Duo. Authenticate for step 1. Checking if user belong to Duo group" 113 is_member_duo_group = self.isUserMemberOfGroup(user, self.audit_attribute, self.duo_group)
114 if (is_member_duo_group):
115 print "Duo. Authenticate for step 1. User '" + user.getUserId() +
"' member of Duo group" 116 duo_count_login_steps = 2
118 self.processAuditGroup(user)
119 duo_count_login_steps = 1
121 identity.setWorkingParameter(
"duo_count_login_steps", duo_count_login_steps)
125 print "Duo. Authenticate for step 2" 126 user = authenticationService.getAuthenticatedUser()
128 print "Duo. Authenticate for step 2. Failed to determine user name" 131 user_name = user.getUserId()
133 sig_response_array = requestParameters.get(
"sig_response")
134 if ArrayHelper.isEmpty(sig_response_array):
135 print "Duo. Authenticate for step 2. sig_response is empty" 138 duo_sig_response = sig_response_array[0]
140 print "Duo. Authenticate for step 2. duo_sig_response: " + duo_sig_response
144 print "Duo. Authenticate for step 2. authenticated_username: " + authenticated_username +
", expected user_name: " + user_name
146 if (
not StringHelper.equals(user_name, authenticated_username)):
149 self.processAuditGroup(user)
def verify_response(ikey, skey, akey, sig_response)
Definition: duo_web.py:154