Skip to content

Commit

Permalink
fix(oxauth): Indentation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
maduvena authored Oct 31, 2023
1 parent c2cc1a9 commit 3f2459c
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,16 @@ def authenticate(self, configurationAttributes, requestParameters, step):
identity = CdiUtil.bean(Identity)

state = ServerUtil.getFirstValue(requestParameters, "state")
# Get state to verify consistency and originality
# Get state to verify consistency and originality
if identity.getWorkingParameter('state_duo') == state :

# Get authorization token to trade for 2FA
duoCode = ServerUtil.getFirstValue(requestParameters, "duo_code")
try:
try:
token = self.duo_client.exchangeAuthorizationCodeFor2FAResult(duoCode, identity.getWorkingParameter('username'))
print "token status %s " % token.getAuth_result().getStatus()
except:
# Handle authentication failure.
print "token status %s " % token.getAuth_result().getStatus()
except:
# Handle authentication failure.
print "authentication failure", sys.exc_info()[1]
return False

Expand All @@ -128,17 +128,20 @@ def prepareForStep(self, configurationAttributes, requestParameters, step):
return True
elif (step == 2):
identity = CdiUtil.bean(Identity)
user_name = identity.getWorkingParameter('username')
user_name = identity.getWorkingParameter('username')
facesContext = CdiUtil.bean(FacesContext)
request = facesContext.getExternalContext().getRequest()
httpService = CdiUtil.bean(HttpService)
url = httpService.constructServerUrl(request) + "/postlogin.htm"

try:
print "before health check"
self.duo_client = Client(self.client_id,self.client_secret,self.api_hostname,url)
self.duo_client.healthCheck()
print "after health check"
except:
print "Duo-Universal. Duo config error. Verify the values in Duo-Universal.conf are correct ", sys.exc_info()[1]
print "Duo-Universal. Duo config error. Verify the values in Duo-Universal.conf are correct ", sys.exc_info()[1]
return False

state = self.duo_client.generateState()
identity.setWorkingParameter("state_duo",state)
Expand Down

0 comments on commit 3f2459c

Please sign in to comment.