From cb6d4f9b2772417aa419906cd95915f4608bf3eb Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 4 Sep 2023 18:25:08 +0200 Subject: [PATCH] fix more stuff Signed-off-by: Jens Langhammer --- authentik/stages/authenticator_mobile/models.py | 8 +++++++- authentik/stages/authenticator_validate/challenge.py | 4 ++-- authentik/stages/authenticator_validate/stage.py | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/authentik/stages/authenticator_mobile/models.py b/authentik/stages/authenticator_mobile/models.py index 159665258..1361cf7dd 100644 --- a/authentik/stages/authenticator_mobile/models.py +++ b/authentik/stages/authenticator_mobile/models.py @@ -121,8 +121,13 @@ class MobileDevice(SerializerModel, Device): notification=AndroidNotification(icon="stock_ticker_update", color="#f45342"), ), apns=APNSConfig( + headers={"apns-push-type": "alert", "apns-priority": "10"}, payload=APNSPayload( - aps=Aps(badge=0), + aps=Aps( + badge=0, + sound="default", + content_available=True, + ), interruption_level="time-sensitive", ), ), @@ -133,6 +138,7 @@ class MobileDevice(SerializerModel, Device): LOGGER.debug("Sent notification", id=response) except (ValueError, FirebaseError) as exc: LOGGER.warning("failed to push", exc=exc) + return True def __str__(self): return str(self.name) or str(self.user) diff --git a/authentik/stages/authenticator_validate/challenge.py b/authentik/stages/authenticator_validate/challenge.py index 79ee49be2..e05ca8770 100644 --- a/authentik/stages/authenticator_validate/challenge.py +++ b/authentik/stages/authenticator_validate/challenge.py @@ -193,9 +193,9 @@ def validate_challenge_mobile(device_pk: str, stage_view: StageView, user: User) ).name try: - response = device.send_message(**push_context) + response = device.send_message(stage_view.request, **push_context) # {'result': 'allow', 'status': 'allow', 'status_msg': 'Success. Logging you in...'} - if response["result"] == "deny": + if not response: LOGGER.debug("mobile push response", result=response) login_failed.send( sender=__name__, diff --git a/authentik/stages/authenticator_validate/stage.py b/authentik/stages/authenticator_validate/stage.py index 4a195adce..5fdc99833 100644 --- a/authentik/stages/authenticator_validate/stage.py +++ b/authentik/stages/authenticator_validate/stage.py @@ -197,7 +197,7 @@ class AuthenticatorValidateStageView(ChallengeStageView): challenge = DeviceChallenge( data={ "device_class": device_class, - "device_uid": device.pk, + "device_uid": str(device.pk), "challenge": get_challenge_for_device(self.request, stage, device), } )