From 00fb77e3da0a36ecf611cfc9af01cbb5b530c03c Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 21 Sep 2023 17:30:01 +0200 Subject: [PATCH] move firebase config to db for testing Signed-off-by: Jens Langhammer --- .../stages/authenticator_mobile/api/stage.py | 1 + ...uthenticatormobilestage_firebase_config.py | 20 +++++++++++++++++++ .../stages/authenticator_mobile/models.py | 5 +++-- blueprints/schema.json | 6 ++++++ schema.yml | 12 +++++++++++ schemas/authentik-cloud-gateway.yml | 2 +- .../AuthenticatorMobileStageForm.ts | 12 +++++++++++ 7 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 authentik/stages/authenticator_mobile/migrations/0005_authenticatormobilestage_firebase_config.py diff --git a/authentik/stages/authenticator_mobile/api/stage.py b/authentik/stages/authenticator_mobile/api/stage.py index 61fc78bcd..2cac56b02 100644 --- a/authentik/stages/authenticator_mobile/api/stage.py +++ b/authentik/stages/authenticator_mobile/api/stage.py @@ -14,6 +14,7 @@ class AuthenticatorMobileStageSerializer(StageSerializer): fields = StageSerializer.Meta.fields + [ "configure_flow", "friendly_name", + "firebase_config", ] diff --git a/authentik/stages/authenticator_mobile/migrations/0005_authenticatormobilestage_firebase_config.py b/authentik/stages/authenticator_mobile/migrations/0005_authenticatormobilestage_firebase_config.py new file mode 100644 index 000000000..f10a6e3cd --- /dev/null +++ b/authentik/stages/authenticator_mobile/migrations/0005_authenticatormobilestage_firebase_config.py @@ -0,0 +1,20 @@ +# Generated by Django 4.2.5 on 2023-09-21 15:27 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ( + "authentik_stages_authenticator_mobile", + "0004_mobiledevice_last_checkin_mobiledevice_state", + ), + ] + + operations = [ + migrations.AddField( + model_name="authenticatormobilestage", + name="firebase_config", + field=models.JSONField(default=dict, help_text="temp"), + ), + ] diff --git a/authentik/stages/authenticator_mobile/models.py b/authentik/stages/authenticator_mobile/models.py index 019344392..262641d7f 100644 --- a/authentik/stages/authenticator_mobile/models.py +++ b/authentik/stages/authenticator_mobile/models.py @@ -43,6 +43,8 @@ def default_token_key(): class AuthenticatorMobileStage(ConfigurableStage, FriendlyNamedStage, Stage): """Setup Mobile authenticator devices""" + firebase_config = models.JSONField(default=dict, help_text="temp") + @property def serializer(self) -> type[BaseSerializer]: from authentik.stages.authenticator_mobile.api.stage import ( @@ -125,8 +127,7 @@ class MobileTransaction(ExpiringModel): def send_message(self, request: Optional[HttpRequest], **context): """Send mobile message""" - cred = credentials.Certificate("firebase.json") - initialize_app(cred) + initialize_app(credentials.Certificate(self.device.stage.firebase_config)) branding = DEFAULT_TENANT.branding_title domain = "" if request: diff --git a/blueprints/schema.json b/blueprints/schema.json index 2cda55d09..68dcddd90 100644 --- a/blueprints/schema.json +++ b/blueprints/schema.json @@ -6143,6 +6143,12 @@ ], "minLength": 1, "title": "Friendly name" + }, + "firebase_config": { + "type": "object", + "additionalProperties": true, + "title": "Firebase config", + "description": "temp" } }, "required": [] diff --git a/schema.yml b/schema.yml index 963863875..4a6b9f0a6 100644 --- a/schema.yml +++ b/schema.yml @@ -30424,6 +30424,10 @@ components: friendly_name: type: string nullable: true + firebase_config: + type: object + additionalProperties: {} + description: temp required: - component - meta_model_name @@ -30452,6 +30456,10 @@ components: type: string nullable: true minLength: 1 + firebase_config: + type: object + additionalProperties: {} + description: temp required: - name AuthenticatorSMSChallenge: @@ -38215,6 +38223,10 @@ components: type: string nullable: true minLength: 1 + firebase_config: + type: object + additionalProperties: {} + description: temp PatchedAuthenticatorSMSStageRequest: type: object description: AuthenticatorSMSStage Serializer diff --git a/schemas/authentik-cloud-gateway.yml b/schemas/authentik-cloud-gateway.yml index 523f6bae4..b6a0240ad 100644 --- a/schemas/authentik-cloud-gateway.yml +++ b/schemas/authentik-cloud-gateway.yml @@ -1,7 +1,7 @@ openapi: 3.0.3 info: title: authentik - version: 2023.8.2 + version: 2023.8.3 description: Making authentication simple. contact: email: hello@goauthentik.io diff --git a/web/src/admin/stages/authenticator_mobile/AuthenticatorMobileStageForm.ts b/web/src/admin/stages/authenticator_mobile/AuthenticatorMobileStageForm.ts index d7ad6be2a..296a1cffe 100644 --- a/web/src/admin/stages/authenticator_mobile/AuthenticatorMobileStageForm.ts +++ b/web/src/admin/stages/authenticator_mobile/AuthenticatorMobileStageForm.ts @@ -83,6 +83,18 @@ export class AuthenticatorMobileStageForm extends ModelForm ${msg("Stage-specific settings")}
+ + + +

${msg("Firebase JSON.")}

+