web/admin: auto set the embedded outpost's authentik_host on first view
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
8e6fcfe350
commit
8599d9efe0
|
@ -116,6 +116,7 @@ class OutpostFilter(FilterSet):
|
|||
"providers": ["isnull"],
|
||||
"name": ["iexact", "icontains"],
|
||||
"service_connection__name": ["iexact", "icontains"],
|
||||
"managed": ["iexact", "icontains"]
|
||||
}
|
||||
|
||||
|
||||
|
|
16
schema.yml
16
schema.yml
|
@ -5723,6 +5723,14 @@ paths:
|
|||
operationId: outposts_instances_list
|
||||
description: Outpost Viewset
|
||||
parameters:
|
||||
- in: query
|
||||
name: managed__icontains
|
||||
schema:
|
||||
type: string
|
||||
- in: query
|
||||
name: managed__iexact
|
||||
schema:
|
||||
type: string
|
||||
- in: query
|
||||
name: name__icontains
|
||||
schema:
|
||||
|
@ -5931,6 +5939,14 @@ paths:
|
|||
operationId: outposts_instances_health_list
|
||||
description: Get outposts current health
|
||||
parameters:
|
||||
- in: query
|
||||
name: managed__icontains
|
||||
schema:
|
||||
type: string
|
||||
- in: query
|
||||
name: managed__iexact
|
||||
schema:
|
||||
type: string
|
||||
- in: query
|
||||
name: name__icontains
|
||||
schema:
|
||||
|
|
|
@ -3199,6 +3199,10 @@ msgstr "OAuth Authorization Codes"
|
|||
msgid "OAuth Refresh Codes"
|
||||
msgstr "OAuth Refresh Codes"
|
||||
|
||||
#: src/pages/admin-overview/cards/SystemStatusCard.ts
|
||||
msgid "OK"
|
||||
msgstr "OK"
|
||||
|
||||
#: src/pages/events/EventInfo.ts
|
||||
#: src/pages/events/EventInfo.ts
|
||||
msgid "Object"
|
||||
|
|
|
@ -3175,6 +3175,10 @@ msgstr "Code d'autorisation OAuth"
|
|||
msgid "OAuth Refresh Codes"
|
||||
msgstr "Code de rafraîchissement OAuth"
|
||||
|
||||
#: src/pages/admin-overview/cards/SystemStatusCard.ts
|
||||
msgid "OK"
|
||||
msgstr ""
|
||||
|
||||
#: src/pages/events/EventInfo.ts
|
||||
#: src/pages/events/EventInfo.ts
|
||||
msgid "Object"
|
||||
|
|
|
@ -3189,6 +3189,10 @@ msgstr ""
|
|||
msgid "OAuth Refresh Codes"
|
||||
msgstr ""
|
||||
|
||||
#: src/pages/admin-overview/cards/SystemStatusCard.ts
|
||||
msgid "OK"
|
||||
msgstr ""
|
||||
|
||||
#: src/pages/events/EventInfo.ts
|
||||
#: src/pages/events/EventInfo.ts
|
||||
msgid "Object"
|
||||
|
|
|
@ -3,7 +3,7 @@ import { t } from "@lingui/macro";
|
|||
import { TemplateResult, html } from "lit";
|
||||
import { customElement } from "lit/decorators.js";
|
||||
|
||||
import { AdminApi, System } from "@goauthentik/api";
|
||||
import { AdminApi, OutpostsApi, System } from "@goauthentik/api";
|
||||
|
||||
import { DEFAULT_CONFIG } from "../../../api/Config";
|
||||
import { AdminStatus, AdminStatusCard } from "./AdminStatusCard";
|
||||
|
@ -12,11 +12,34 @@ import { AdminStatus, AdminStatusCard } from "./AdminStatusCard";
|
|||
export class SystemStatusCard extends AdminStatusCard<System> {
|
||||
now?: Date;
|
||||
|
||||
header = "OK";
|
||||
header = t`OK`;
|
||||
|
||||
getPrimaryValue(): Promise<System> {
|
||||
async getPrimaryValue(): Promise<System> {
|
||||
this.now = new Date();
|
||||
return new AdminApi(DEFAULT_CONFIG).adminSystemRetrieve();
|
||||
let status = await new AdminApi(DEFAULT_CONFIG).adminSystemRetrieve();
|
||||
if (status.embeddedOutpostHost === "") {
|
||||
// First install, ensure the embedded outpost host is set
|
||||
await this.setOutpostHost();
|
||||
status = await new AdminApi(DEFAULT_CONFIG).adminSystemRetrieve();
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// Called on fresh installations and whenever the embedded outpost is deleted
|
||||
// automatically send the login URL when the user first visits the admin dashboard.
|
||||
async setOutpostHost(): Promise<void> {
|
||||
const outposts = await new OutpostsApi(DEFAULT_CONFIG).outpostsInstancesList({
|
||||
managedIexact: "goauthentik.io/outposts/embedded",
|
||||
});
|
||||
if (outposts.results.length < 1) {
|
||||
return;
|
||||
}
|
||||
const outpost = outposts.results[0];
|
||||
outpost.config["authentik_host"] = window.location.origin;
|
||||
await new OutpostsApi(DEFAULT_CONFIG).outpostsInstancesUpdate({
|
||||
uuid: outpost.pk,
|
||||
outpostRequest: outpost,
|
||||
});
|
||||
}
|
||||
|
||||
getStatus(value: System): Promise<AdminStatus> {
|
||||
|
|
Reference in a new issue