Skip to content

Commit

Permalink
feat(fido2): allow to update device data in SG authentication response
Browse files Browse the repository at this point in the history
jans #8116
  • Loading branch information
yurem committed Mar 26, 2024
1 parent 0d69613 commit 4522020
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ def sendPushNotificationImpl(self, client_redirect_uri, user, super_gluu_request
pushSnsService = CdiUtil.bean(PushSnsService)
targetEndpointArn = self.getTargetEndpointArn(deviceRegistrationService, pushSnsService, PushPlatform.APNS, user, u2f_device)
if targetEndpointArn == None:
return
return

send_notification = True

Expand Down Expand Up @@ -866,7 +866,7 @@ def sendPushNotificationImpl(self, client_redirect_uri, user, super_gluu_request
pushSnsService = CdiUtil.bean(PushSnsService)
targetEndpointArn = self.getTargetEndpointArn(deviceRegistrationService, pushSnsService, PushPlatform.GCM, user, u2f_device)
if targetEndpointArn == None:
return
return

send_notification = True

Expand Down Expand Up @@ -904,12 +904,12 @@ def getTargetEndpointArn(self, deviceRegistrationService, pushSnsService, platfo

# Return endpoint ARN if it created already
notificationConf = u2fDevice.getDeviceNotificationConf()
notificationConfJson = {}
if StringHelper.isNotEmpty(notificationConf):
notificationConfJson = json.loads(notificationConf)
targetEndpointArn = notificationConfJson['sns_endpoint_arn']
if StringHelper.isNotEmpty(targetEndpointArn):
if 'sns_endpoint_arn' in notificationConfJson:
print "Super-Gluu. Get target endpoint ARN. There is already created target endpoint ARN"
return targetEndpointArn
return notificationConfJson['sns_endpoint_arn']

# Create endpoint ARN
pushClient = None
Expand Down Expand Up @@ -944,15 +944,16 @@ def getTargetEndpointArn(self, deviceRegistrationService, pushSnsService, platfo
targetEndpointArn = registerDeviceResponse.getEndpointArn()

if StringHelper.isEmpty(targetEndpointArn):
print "Super-Gluu. Failed to get endpoint ARN for user: '%s'" % user.getUserId()
return None
print "Super-Gluu. Failed to get endpoint ARN for user: '%s'" % user.getUserId()
return None

print "Super-Gluu. Get target endpoint ARN. Create target endpoint ARN '%s' for user: '%s'" % (targetEndpointArn, user.getUserId())

# Store created endpoint ARN in device entry
notificationConfJson['sns_endpoint_arn'] = targetEndpointArn
userInum = user.getAttribute("inum")
u2fDeviceUpdate = deviceRegistrationService.findUserDeviceRegistration(userInum, u2fDevice.getId())
u2fDeviceUpdate.setDeviceNotificationConf('{"sns_endpoint_arn" : "%s"}' % targetEndpointArn)
u2fDeviceUpdate.setDeviceNotificationConf(json.dumps(notificationConfJson))
deviceRegistrationService.updateDeviceRegistration(userInum, u2fDeviceUpdate)

return targetEndpointArn
Expand Down

0 comments on commit 4522020

Please sign in to comment.