Skip to content

Commit

Permalink
fix: update how external uids are retrieved #8478
Browse files Browse the repository at this point in the history
Signed-off-by: jgomer2001 <bonustrack310@gmail.com>
  • Loading branch information
jgomer2001 committed May 14, 2024
1 parent 820e53a commit 1c2b147
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions jans-casa/extras/casa-external_otp.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,15 +358,15 @@ def findEnrollments(self, user_name, otpType, skipPrefix = True):
print "OTP. Find enrollments. Failed to find user"
return result

user_custom_ext_attribute = userService.getCustomAttribute(user, "jansExtUid")
if user_custom_ext_attribute == None:
extUids = user.getExternalUid()
if extUids == None:
return result

#otp_prefix = "%s:" % self.otpType
otp_prefix = "%s:" % otpType

otp_prefix_length = len(otp_prefix)
for user_external_uid in user_custom_ext_attribute.getValues():
for user_external_uid in extUids:
index = user_external_uid.find(otp_prefix)
if index != -1:
if skipPrefix:
Expand Down Expand Up @@ -449,7 +449,6 @@ def processOtpAuthentication(self, requestParameters, user_name, identity, otp_a
# print "OTP. Process OTP authentication. There is no OTP enrollment for user '%s'" % user_name
# facesMessages.add(FacesMessage.SEVERITY_ERROR, "There is no valid OTP user enrollments")
# return False

if len(user_enrollments) > 0:
for user_enrollment in user_enrollments:
user_enrollment_data = user_enrollment.split(";")
Expand All @@ -474,7 +473,6 @@ def processOtpAuthentication(self, requestParameters, user_name, identity, otp_a
print "OTP. Process HOTP authentication during authentication. Failed to update user entry"

user_enrollments = self.findEnrollments(user_name, "totp")

if len(user_enrollments) > 0:
for user_enrollment in user_enrollments:
otp_secret_key = self.fromBase64Url(user_enrollment)
Expand Down

0 comments on commit 1c2b147

Please sign in to comment.