move firebase config to db for testing

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens Langhammer 2023-09-21 17:30:01 +02:00
parent 9edccb1a9d
commit 00fb77e3da
No known key found for this signature in database
7 changed files with 55 additions and 3 deletions

View File

@ -14,6 +14,7 @@ class AuthenticatorMobileStageSerializer(StageSerializer):
fields = StageSerializer.Meta.fields + [
"configure_flow",
"friendly_name",
"firebase_config",
]

View File

@ -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"),
),
]

View File

@ -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:

View File

@ -6143,6 +6143,12 @@
],
"minLength": 1,
"title": "Friendly name"
},
"firebase_config": {
"type": "object",
"additionalProperties": true,
"title": "Firebase config",
"description": "temp"
}
},
"required": []

View File

@ -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

View File

@ -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

View File

@ -83,6 +83,18 @@ export class AuthenticatorMobileStageForm extends ModelForm<AuthenticatorMobileS
<ak-form-group .expanded=${true}>
<span slot="header"> ${msg("Stage-specific settings")} </span>
<div slot="body" class="pf-c-form">
<ak-form-element-horizontal
label=${msg("Firebase config")}
?required=${false}
name="firebaseConfig"
>
<ak-codemirror
mode="javascript"
value="${first(this.instance?.firebaseConfig, {})}"
>
</ak-codemirror>
<p class="pf-c-form__helper-text">${msg("Firebase JSON.")}</p>
</ak-form-element-horizontal>
<ak-form-element-horizontal
label=${msg("Configuration flow")}
name="configureFlow"