From 9d4c22c7061393fc295569c97ae68ebf0c50a06f Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 19 Feb 2021 19:33:58 +0100 Subject: [PATCH] web: show header while loading application info --- authentik/flows/api/stages.py | 2 +- authentik/flows/transfer/common.py | 1 + authentik/flows/transfer/importer.py | 19 +- swagger.yaml | 237 ++++++++++++------ .../pages/applications/ApplicationViewPage.ts | 9 +- web/src/pages/tokens/TokenListPage.ts | 7 +- 6 files changed, 186 insertions(+), 89 deletions(-) diff --git a/authentik/flows/api/stages.py b/authentik/flows/api/stages.py index 56ba52937..661a6e537 100644 --- a/authentik/flows/api/stages.py +++ b/authentik/flows/api/stages.py @@ -18,7 +18,7 @@ class StageSerializer(ModelSerializer, MetaNameSerializer): """Stage Serializer""" object_type = SerializerMethodField() - flow_set = FlowSerializer(many=True) + flow_set = FlowSerializer(many=True, required=False) def get_object_type(self, obj: Stage) -> str: """Get object type so that we know which API Endpoint to use to get the full object""" diff --git a/authentik/flows/transfer/common.py b/authentik/flows/transfer/common.py index 590b15e03..2b1173942 100644 --- a/authentik/flows/transfer/common.py +++ b/authentik/flows/transfer/common.py @@ -22,6 +22,7 @@ def get_attrs(obj: SerializerModel) -> dict[str, Any]: "verbose_name", "verbose_name_plural", "object_type", + "flow_set", ) for to_remove_name in to_remove: if to_remove_name in data: diff --git a/authentik/flows/transfer/importer.py b/authentik/flows/transfer/importer.py index 2839668a8..fd5ab82b6 100644 --- a/authentik/flows/transfer/importer.py +++ b/authentik/flows/transfer/importer.py @@ -65,14 +65,17 @@ class FlowImporter: return value for key, value in attrs.items(): - if isinstance(value, dict): - for idx, _inner_key in enumerate(value): - value[_inner_key] = updater(value[_inner_key]) - elif isinstance(value, list): - for idx, _inner_value in enumerate(value): - attrs[key][idx] = updater(_inner_value) - else: - attrs[key] = updater(value) + try: + if isinstance(value, dict): + for idx, _inner_key in enumerate(value): + value[_inner_key] = updater(value[_inner_key]) + elif isinstance(value, list): + for idx, _inner_value in enumerate(value): + attrs[key][idx] = updater(_inner_value) + else: + attrs[key] = updater(value) + except TypeError: + continue return attrs def __query_from_identifier(self, attrs: dict[str, Any]) -> Q: diff --git a/swagger.yaml b/swagger.yaml index 2cc4d87bd..78110582e 100755 --- a/swagger.yaml +++ b/swagger.yaml @@ -8570,82 +8570,6 @@ definitions: webhook_url: title: Webhook url type: string - Stage: - title: Stage obj - description: Stage Serializer - required: - - name - type: object - properties: - pk: - title: Stage uuid - type: string - format: uuid - readOnly: true - name: - title: Name - type: string - minLength: 1 - object_type: - title: Object type - type: string - readOnly: true - verbose_name: - title: Verbose name - type: string - readOnly: true - verbose_name_plural: - title: Verbose name plural - type: string - readOnly: true - FlowStageBinding: - description: FlowStageBinding Serializer - required: - - target - - stage - - order - type: object - properties: - pk: - title: Fsb uuid - type: string - format: uuid - readOnly: true - policybindingmodel_ptr_id: - title: Policybindingmodel ptr id - type: string - readOnly: true - target: - title: Target - type: string - format: uuid - stage: - title: Stage - type: string - format: uuid - stage_obj: - $ref: '#/definitions/Stage' - evaluate_on_plan: - title: Evaluate on plan - description: Evaluate policies during the Flow planning process. Disable this - for input-based policies. - type: boolean - re_evaluate_policies: - title: Re evaluate policies - description: Evaluate policies when the Stage is present to the user. - type: boolean - order: - title: Order - type: integer - maximum: 2147483647 - minimum: -2147483648 - policies: - type: array - items: - type: string - format: uuid - readOnly: true - uniqueItems: true Flow: description: Flow Serializer required: @@ -8718,6 +8642,87 @@ definitions: title: Cache count type: string readOnly: true + Stage: + title: Stage obj + description: Stage Serializer + required: + - name + type: object + properties: + pk: + title: Stage uuid + type: string + format: uuid + readOnly: true + name: + title: Name + type: string + minLength: 1 + object_type: + title: Object type + type: string + readOnly: true + verbose_name: + title: Verbose name + type: string + readOnly: true + verbose_name_plural: + title: Verbose name plural + type: string + readOnly: true + flow_set: + description: '' + type: array + items: + $ref: '#/definitions/Flow' + FlowStageBinding: + description: FlowStageBinding Serializer + required: + - target + - stage + - order + type: object + properties: + pk: + title: Fsb uuid + type: string + format: uuid + readOnly: true + policybindingmodel_ptr_id: + title: Policybindingmodel ptr id + type: string + readOnly: true + target: + title: Target + type: string + format: uuid + stage: + title: Stage + type: string + format: uuid + stage_obj: + $ref: '#/definitions/Stage' + evaluate_on_plan: + title: Evaluate on plan + description: Evaluate policies during the Flow planning process. Disable this + for input-based policies. + type: boolean + re_evaluate_policies: + title: Re evaluate policies + description: Evaluate policies when the Stage is present to the user. + type: boolean + order: + title: Order + type: integer + maximum: 2147483647 + minimum: -2147483648 + policies: + type: array + items: + type: string + format: uuid + readOnly: true + uniqueItems: true Cache: description: Generic cache stats for an object type: object @@ -10913,6 +10918,11 @@ definitions: title: Verbose name plural type: string readOnly: true + flow_set: + description: '' + type: array + items: + $ref: '#/definitions/Flow' configure_flow: title: Configure flow description: Flow used by an authenticated user to configure this Stage. If @@ -10953,6 +10963,11 @@ definitions: title: Verbose name plural type: string readOnly: true + flow_set: + description: '' + type: array + items: + $ref: '#/definitions/Flow' configure_flow: title: Configure flow description: Flow used by an authenticated user to configure this Stage. If @@ -10993,6 +11008,11 @@ definitions: title: Verbose name plural type: string readOnly: true + flow_set: + description: '' + type: array + items: + $ref: '#/definitions/Flow' not_configured_action: title: Not configured action type: string @@ -11032,6 +11052,11 @@ definitions: title: Verbose name plural type: string readOnly: true + flow_set: + description: '' + type: array + items: + $ref: '#/definitions/Flow' CaptchaStage: description: CaptchaStage Serializer required: @@ -11061,6 +11086,11 @@ definitions: title: Verbose name plural type: string readOnly: true + flow_set: + description: '' + type: array + items: + $ref: '#/definitions/Flow' public_key: title: Public key description: Public key, acquired from https://www.google.com/recaptcha/intro/v3.html @@ -11098,6 +11128,11 @@ definitions: title: Verbose name plural type: string readOnly: true + flow_set: + description: '' + type: array + items: + $ref: '#/definitions/Flow' mode: title: Mode type: string @@ -11137,6 +11172,11 @@ definitions: title: Verbose name plural type: string readOnly: true + flow_set: + description: '' + type: array + items: + $ref: '#/definitions/Flow' EmailStage: description: EmailStage Serializer required: @@ -11164,6 +11204,11 @@ definitions: title: Verbose name plural type: string readOnly: true + flow_set: + description: '' + type: array + items: + $ref: '#/definitions/Flow' use_global_settings: title: Use global settings description: When enabled, global Email connection settings will be used and @@ -11246,6 +11291,11 @@ definitions: title: Verbose name plural type: string readOnly: true + flow_set: + description: '' + type: array + items: + $ref: '#/definitions/Flow' user_fields: description: '' type: array @@ -11312,6 +11362,11 @@ definitions: title: Verbose name plural type: string readOnly: true + flow_set: + description: '' + type: array + items: + $ref: '#/definitions/Flow' continue_flow_without_invitation: title: Continue flow without invitation description: If this flag is set, this Stage will jump to the next Stage when @@ -11364,6 +11419,11 @@ definitions: title: Verbose name plural type: string readOnly: true + flow_set: + description: '' + type: array + items: + $ref: '#/definitions/Flow' backends: description: '' type: array @@ -11464,6 +11524,11 @@ definitions: title: Verbose name plural type: string readOnly: true + flow_set: + description: '' + type: array + items: + $ref: '#/definitions/Flow' fields: type: array items: @@ -11503,6 +11568,11 @@ definitions: title: Verbose name plural type: string readOnly: true + flow_set: + description: '' + type: array + items: + $ref: '#/definitions/Flow' UserLoginStage: description: UserLoginStage Serializer required: @@ -11530,6 +11600,11 @@ definitions: title: Verbose name plural type: string readOnly: true + flow_set: + description: '' + type: array + items: + $ref: '#/definitions/Flow' session_duration: title: Session duration description: 'Determines how long a session lasts. Default of 0 means that @@ -11563,6 +11638,11 @@ definitions: title: Verbose name plural type: string readOnly: true + flow_set: + description: '' + type: array + items: + $ref: '#/definitions/Flow' UserWriteStage: description: UserWriteStage Serializer required: @@ -11590,3 +11670,8 @@ definitions: title: Verbose name plural type: string readOnly: true + flow_set: + description: '' + type: array + items: + $ref: '#/definitions/Flow' diff --git a/web/src/pages/applications/ApplicationViewPage.ts b/web/src/pages/applications/ApplicationViewPage.ts index 3b38bae6a..7ac812315 100644 --- a/web/src/pages/applications/ApplicationViewPage.ts +++ b/web/src/pages/applications/ApplicationViewPage.ts @@ -38,7 +38,14 @@ export class ApplicationViewPage extends LitElement { render(): TemplateResult { if (!this.application) { - return html``; + return html`
+
+

+ ${gettext("Loading...")} +

+
+
+ `; } return html`
diff --git a/web/src/pages/tokens/TokenListPage.ts b/web/src/pages/tokens/TokenListPage.ts index dc4645bd5..488971c17 100644 --- a/web/src/pages/tokens/TokenListPage.ts +++ b/web/src/pages/tokens/TokenListPage.ts @@ -5,6 +5,7 @@ import { TablePage } from "../../elements/table/TablePage"; import "../../elements/buttons/ModalButton"; import "../../elements/buttons/Dropdown"; +import "../../elements/buttons/TokenCopyButton"; import { TableColumn } from "../../elements/table/Table"; import { Token } from "../../api/Tokens"; @@ -49,16 +50,16 @@ export class TokenListPage extends TablePage { html`${item.identifier}`, html`${item.user.username}`, html`${item.expiring ? "Yes" : "No"}`, - html`${item.expiring ? new Date(item.expires * 1000).toLocaleString() : '-'}`, + html`${item.expiring ? new Date(item.expires * 1000).toLocaleString() : "-"}`, html` - ${gettext('Delete')} + ${gettext("Delete")}
- ${gettext('Copy Key')} + ${gettext("Copy Key")} `, ];