web/admin: show banner when backend and frontend versions mismatch

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-04-13 16:38:50 +02:00
parent 1b79fad6cf
commit 55bb9b6643
8 changed files with 70 additions and 61 deletions

View file

@ -6,7 +6,7 @@ from drf_yasg.utils import swagger_auto_schema
from packaging.version import parse
from rest_framework.fields import SerializerMethodField
from rest_framework.mixins import ListModelMixin
from rest_framework.permissions import IsAdminUser
from rest_framework.permissions import IsAuthenticated
from rest_framework.request import Request
from rest_framework.response import Response
from rest_framework.viewsets import GenericViewSet
@ -50,7 +50,9 @@ class VersionSerializer(PassiveSerializer):
class VersionViewSet(ListModelMixin, GenericViewSet):
"""Get running and latest version."""
permission_classes = [IsAdminUser]
permission_classes = [IsAuthenticated]
pagination_class = None
filter_backends = []
def get_queryset(self): # pragma: no cover
return None

View file

@ -52,7 +52,6 @@ class EmailStageViewSet(ModelViewSet):
queryset = EmailStage.objects.all()
serializer_class = EmailStageSerializer
# TODO: Validate connection settings when use_global_settings is unchecked
@swagger_auto_schema(responses={200: TypeCreateSerializer(many=True)})
@action(detail=False, pagination_class=None, filter_backends=[])
def templates(self, request: Request) -> Response:

View file

@ -131,27 +131,7 @@ paths:
get:
operationId: admin_version_list
description: Get running and latest version.
parameters:
- name: ordering
in: query
description: Which field to use when ordering the results.
required: false
type: string
- name: search
in: query
description: A search term.
required: false
type: string
- name: page
in: query
description: Page Index
required: false
type: integer
- name: page_size
in: query
description: Page Size
required: false
type: integer
parameters: []
responses:
'200':
description: ''

View file

@ -2,7 +2,6 @@ import { css, CSSResult, html, LitElement, property, TemplateResult } from "lit-
import { SidebarItem } from "../elements/sidebar/Sidebar";
import PFBase from "@patternfly/patternfly/patternfly-base.css";
import PFPage from "@patternfly/patternfly/components/Page/page.css";
import PFSkipToContent from "@patternfly/patternfly/components/SkipToContent/skip-to-content.css";
import PFButton from "@patternfly/patternfly/components/Button/button.css";
import PFDrawer from "@patternfly/patternfly/components/Drawer/drawer.css";
@ -13,7 +12,9 @@ import "../elements/Banner";
import { until } from "lit-html/directives/until";
import { me } from "../api/Users";
import { t } from "@lingui/macro";
import { EVENT_NOTIFICATION_TOGGLE, EVENT_SIDEBAR_TOGGLE } from "../constants";
import { EVENT_NOTIFICATION_TOGGLE, EVENT_SIDEBAR_TOGGLE, VERSION } from "../constants";
import { AdminApi } from "authentik-api";
import { DEFAULT_CONFIG } from "../api/Config";
export abstract class Interface extends LitElement {
@property({type: Boolean})
@ -25,7 +26,7 @@ export abstract class Interface extends LitElement {
abstract get sidebar(): SidebarItem[];
static get styles(): CSSResult[] {
return [PFBase, PFPage, PFSkipToContent, PFButton, PFDrawer, css`
return [PFBase, PFPage, PFButton, PFDrawer, css`
.pf-c-page__main, .pf-c-drawer__content, .pf-c-page__drawer {
z-index: auto !important;
}
@ -48,6 +49,17 @@ export abstract class Interface extends LitElement {
render(): TemplateResult {
return html`
${until(new AdminApi(DEFAULT_CONFIG).adminVersionList().then(version => {
if (version.versionCurrent !== VERSION) {
return html`<ak-banner>
${t`A newer version of the frontend is available.`}
<button @click=${() => { window.location.reload(); }}>
${t`Reload`}
</button>
</ak-banner>`;
}
return html``;
}))}
${until(me().then((u) => {
if (u.original) {
return html`<ak-banner>

View file

@ -25,6 +25,10 @@ msgstr "6 digits, widely compatible"
msgid "8 digits, not compatible with apps like Google Authenticator"
msgstr "8 digits, not compatible with apps like Google Authenticator"
#: src/interfaces/Interface.ts:50
msgid "A newer version of the frontend is available."
msgstr "A newer version of the frontend is available."
#: src/pages/policies/dummy/DummyPolicyForm.ts:53
msgid "A policy used for testing. Always returns the same result as specified below after waiting a random duration."
msgstr "A policy used for testing. Always returns the same result as specified below after waiting a random duration."
@ -462,7 +466,7 @@ msgstr "Change password"
msgid "Change your password"
msgstr "Change your password"
#: src/pages/applications/ApplicationViewPage.ts:119
#: src/pages/applications/ApplicationViewPage.ts:123
#: src/pages/flows/FlowViewPage.ts:110
#: src/pages/providers/oauth2/OAuth2ProviderViewPage.ts:136
#: src/pages/providers/proxy/ProxyProviderViewPage.ts:135
@ -1011,8 +1015,8 @@ msgid "Each provider has a different issuer, based on the application slug."
msgstr "Each provider has a different issuer, based on the application slug."
#: src/pages/applications/ApplicationListPage.ts:94
#: src/pages/applications/ApplicationViewPage.ts:95
#: src/pages/applications/ApplicationViewPage.ts:109
#: src/pages/applications/ApplicationViewPage.ts:91
#: src/pages/applications/ApplicationViewPage.ts:105
#: src/pages/crypto/CertificateKeyPairListPage.ts:74
#: src/pages/events/RuleListPage.ts:70
#: src/pages/events/TransportListPage.ts:74
@ -1676,7 +1680,7 @@ msgstr "Library"
#: src/flows/stages/identification/IdentificationStage.ts:134
#: src/flows/stages/password/PasswordStage.ts:31
#: src/flows/stages/prompt/PromptStage.ts:126
#: src/pages/applications/ApplicationViewPage.ts:60
#: src/pages/applications/ApplicationViewPage.ts:54
#: src/pages/user-settings/UserDetailsPage.ts:38
#: src/utils.ts:40
msgid "Loading"
@ -1756,7 +1760,7 @@ msgid "Logins"
msgstr "Logins"
#: src/pages/admin-overview/AdminOverviewPage.ts:40
#: src/pages/applications/ApplicationViewPage.ts:68
#: src/pages/applications/ApplicationViewPage.ts:115
msgid "Logins over the last 24 hours"
msgstr "Logins over the last 24 hours"
@ -2185,7 +2189,7 @@ msgid "Outposts are deployments of authentik components to support different env
msgstr "Outposts are deployments of authentik components to support different environments and protocols, like reverse proxies."
#: src/interfaces/AdminInterface.ts:17
#: src/pages/applications/ApplicationViewPage.ts:65
#: src/pages/applications/ApplicationViewPage.ts:59
#: src/pages/providers/oauth2/OAuth2ProviderViewPage.ts:65
#: src/pages/providers/proxy/ProxyProviderViewPage.ts:56
#: src/pages/providers/saml/SAMLProviderViewPage.ts:58
@ -2265,7 +2269,7 @@ msgstr "Policy"
msgid "Policy / User / Group"
msgstr "Policy / User / Group"
#: src/pages/applications/ApplicationViewPage.ts:130
#: src/pages/applications/ApplicationViewPage.ts:134
#: src/pages/flows/FlowViewPage.ts:101
#: src/pages/sources/oauth/OAuthSourceViewPage.ts:143
#: src/pages/sources/saml/SAMLSourceViewPage.ts:150
@ -2277,6 +2281,7 @@ msgid "Policy binding"
msgstr "Policy binding"
#: src/pages/applications/ApplicationForm.ts:141
#: src/pages/applications/ApplicationViewPage.ts:81
#: src/pages/flows/FlowForm.ts:101
#: src/pages/flows/StageBindingForm.ts:136
msgid "Policy engine mode"
@ -2384,7 +2389,7 @@ msgstr "Provide support for protocols like SAML and OAuth to assigned applicatio
#: src/elements/oauth/UserRefreshList.ts:29
#: src/pages/applications/ApplicationForm.ts:100
#: src/pages/applications/ApplicationListPage.ts:59
#: src/pages/applications/ApplicationViewPage.ts:82
#: src/pages/applications/ApplicationViewPage.ts:68
#: src/pages/providers/ProviderListPage.ts:34
msgid "Provider"
msgstr "Provider"
@ -2498,11 +2503,15 @@ msgstr "Register device"
msgid "Regular expressions for which authentication is not required. Each new line is interpreted as a new Regular Expression."
msgstr "Regular expressions for which authentication is not required. Each new line is interpreted as a new Regular Expression."
#: src/pages/applications/ApplicationViewPage.ts:76
#: src/pages/applications/ApplicationViewPage.ts:62
#: src/pages/flows/FlowViewPage.ts:64
msgid "Related"
msgstr "Related"
#: src/interfaces/Interface.ts:52
msgid "Reload"
msgstr "Reload"
#: src/pages/stages/user_logout/UserLogoutStageForm.ts:51
msgid "Remove the user from the current session."
msgstr "Remove the user from the current session."
@ -2914,7 +2923,7 @@ msgstr "Status: Disabled"
msgid "Status: Enabled"
msgstr "Status: Enabled"
#: src/interfaces/Interface.ts:51
#: src/interfaces/Interface.ts:63
msgid "Stop impersonation"
msgstr "Stop impersonation"
@ -3297,7 +3306,7 @@ msgstr ""
msgid "These policies control when this stage will be applied to the flow."
msgstr "These policies control when this stage will be applied to the flow."
#: src/pages/applications/ApplicationViewPage.ts:132
#: src/pages/applications/ApplicationViewPage.ts:136
msgid "These policies control which users can access this application."
msgstr "These policies control which users can access this application."
@ -3450,7 +3459,7 @@ msgid "Up-to-date!"
msgstr "Up-to-date!"
#: src/pages/applications/ApplicationListPage.ts:86
#: src/pages/applications/ApplicationViewPage.ts:101
#: src/pages/applications/ApplicationViewPage.ts:97
#: src/pages/crypto/CertificateKeyPairListPage.ts:66
#: src/pages/events/RuleListPage.ts:62
#: src/pages/events/TransportListPage.ts:66
@ -3488,7 +3497,7 @@ msgid "Update"
msgstr "Update"
#: src/pages/applications/ApplicationListPage.ts:89
#: src/pages/applications/ApplicationViewPage.ts:104
#: src/pages/applications/ApplicationViewPage.ts:100
msgid "Update Application"
msgstr "Update Application"
@ -3854,7 +3863,7 @@ msgstr "X509 Subject"
msgid "Yes"
msgstr "Yes"
#: src/interfaces/Interface.ts:49
#: src/interfaces/Interface.ts:61
msgid "You're currently impersonating {0}."
msgstr "You're currently impersonating {0}."

View file

@ -25,6 +25,10 @@ msgstr ""
msgid "8 digits, not compatible with apps like Google Authenticator"
msgstr ""
#: src/interfaces/Interface.ts:50
msgid "A newer version of the frontend is available."
msgstr ""
#: src/pages/policies/dummy/DummyPolicyForm.ts:53
msgid "A policy used for testing. Always returns the same result as specified below after waiting a random duration."
msgstr ""
@ -458,7 +462,7 @@ msgstr ""
msgid "Change your password"
msgstr ""
#: src/pages/applications/ApplicationViewPage.ts:119
#: src/pages/applications/ApplicationViewPage.ts:123
#: src/pages/flows/FlowViewPage.ts:110
#: src/pages/providers/oauth2/OAuth2ProviderViewPage.ts:136
#: src/pages/providers/proxy/ProxyProviderViewPage.ts:135
@ -1003,8 +1007,8 @@ msgid "Each provider has a different issuer, based on the application slug."
msgstr ""
#: src/pages/applications/ApplicationListPage.ts:94
#: src/pages/applications/ApplicationViewPage.ts:95
#: src/pages/applications/ApplicationViewPage.ts:109
#: src/pages/applications/ApplicationViewPage.ts:91
#: src/pages/applications/ApplicationViewPage.ts:105
#: src/pages/crypto/CertificateKeyPairListPage.ts:74
#: src/pages/events/RuleListPage.ts:70
#: src/pages/events/TransportListPage.ts:74
@ -1668,7 +1672,7 @@ msgstr ""
#: src/flows/stages/identification/IdentificationStage.ts:134
#: src/flows/stages/password/PasswordStage.ts:31
#: src/flows/stages/prompt/PromptStage.ts:126
#: src/pages/applications/ApplicationViewPage.ts:60
#: src/pages/applications/ApplicationViewPage.ts:54
#: src/pages/user-settings/UserDetailsPage.ts:38
#: src/utils.ts:40
msgid "Loading"
@ -1748,7 +1752,7 @@ msgid "Logins"
msgstr ""
#: src/pages/admin-overview/AdminOverviewPage.ts:40
#: src/pages/applications/ApplicationViewPage.ts:68
#: src/pages/applications/ApplicationViewPage.ts:115
msgid "Logins over the last 24 hours"
msgstr ""
@ -2177,7 +2181,7 @@ msgid "Outposts are deployments of authentik components to support different env
msgstr ""
#: src/interfaces/AdminInterface.ts:17
#: src/pages/applications/ApplicationViewPage.ts:65
#: src/pages/applications/ApplicationViewPage.ts:59
#: src/pages/providers/oauth2/OAuth2ProviderViewPage.ts:65
#: src/pages/providers/proxy/ProxyProviderViewPage.ts:56
#: src/pages/providers/saml/SAMLProviderViewPage.ts:58
@ -2257,7 +2261,7 @@ msgstr ""
msgid "Policy / User / Group"
msgstr ""
#: src/pages/applications/ApplicationViewPage.ts:130
#: src/pages/applications/ApplicationViewPage.ts:134
#: src/pages/flows/FlowViewPage.ts:101
#: src/pages/sources/oauth/OAuthSourceViewPage.ts:143
#: src/pages/sources/saml/SAMLSourceViewPage.ts:150
@ -2269,6 +2273,7 @@ msgid "Policy binding"
msgstr ""
#: src/pages/applications/ApplicationForm.ts:141
#: src/pages/applications/ApplicationViewPage.ts:81
#: src/pages/flows/FlowForm.ts:101
#: src/pages/flows/StageBindingForm.ts:136
msgid "Policy engine mode"
@ -2376,7 +2381,7 @@ msgstr ""
#: src/elements/oauth/UserRefreshList.ts:29
#: src/pages/applications/ApplicationForm.ts:100
#: src/pages/applications/ApplicationListPage.ts:59
#: src/pages/applications/ApplicationViewPage.ts:82
#: src/pages/applications/ApplicationViewPage.ts:68
#: src/pages/providers/ProviderListPage.ts:34
msgid "Provider"
msgstr ""
@ -2490,11 +2495,15 @@ msgstr ""
msgid "Regular expressions for which authentication is not required. Each new line is interpreted as a new Regular Expression."
msgstr ""
#: src/pages/applications/ApplicationViewPage.ts:76
#: src/pages/applications/ApplicationViewPage.ts:62
#: src/pages/flows/FlowViewPage.ts:64
msgid "Related"
msgstr ""
#: src/interfaces/Interface.ts:52
msgid "Reload"
msgstr ""
#: src/pages/stages/user_logout/UserLogoutStageForm.ts:51
msgid "Remove the user from the current session."
msgstr ""
@ -2906,7 +2915,7 @@ msgstr ""
msgid "Status: Enabled"
msgstr ""
#: src/interfaces/Interface.ts:51
#: src/interfaces/Interface.ts:63
msgid "Stop impersonation"
msgstr ""
@ -3287,7 +3296,7 @@ msgstr ""
msgid "These policies control when this stage will be applied to the flow."
msgstr ""
#: src/pages/applications/ApplicationViewPage.ts:132
#: src/pages/applications/ApplicationViewPage.ts:136
msgid "These policies control which users can access this application."
msgstr ""
@ -3440,7 +3449,7 @@ msgid "Up-to-date!"
msgstr ""
#: src/pages/applications/ApplicationListPage.ts:86
#: src/pages/applications/ApplicationViewPage.ts:101
#: src/pages/applications/ApplicationViewPage.ts:97
#: src/pages/crypto/CertificateKeyPairListPage.ts:66
#: src/pages/events/RuleListPage.ts:62
#: src/pages/events/TransportListPage.ts:66
@ -3478,7 +3487,7 @@ msgid "Update"
msgstr ""
#: src/pages/applications/ApplicationListPage.ts:89
#: src/pages/applications/ApplicationViewPage.ts:104
#: src/pages/applications/ApplicationViewPage.ts:100
msgid "Update Application"
msgstr ""
@ -3842,7 +3851,7 @@ msgstr ""
msgid "Yes"
msgstr ""
#: src/interfaces/Interface.ts:49
#: src/interfaces/Interface.ts:61
msgid "You're currently impersonating {0}."
msgstr ""

View file

@ -8,7 +8,7 @@ import { AdminStatusCard, AdminStatus } from "./AdminStatusCard";
export class VersionStatusCard extends AdminStatusCard<Version> {
getPrimaryValue(): Promise<Version> {
return new AdminApi(DEFAULT_CONFIG).adminVersionList({});
return new AdminApi(DEFAULT_CONFIG).adminVersionList();
}
getStatus(value: Version): Promise<AdminStatus> {

View file

@ -71,16 +71,14 @@ export class EmailStageForm extends Form<EmailStage> {
</ak-form-element-horizontal>
<ak-form-element-horizontal
label=${t`SMTP Username`}
?required=${true}
name="username">
<input type="text" value="${ifDefined(this.stage?.username || "")}" class="pf-c-form-control" required>
<input type="text" value="${ifDefined(this.stage?.username || "")}" class="pf-c-form-control">
</ak-form-element-horizontal>
<ak-form-element-horizontal
label=${t`SMTP Password`}
?required=${true}
?writeOnly=${this.stage !== undefined}
name="password">
<input type="text" value="${ifDefined(this.stage?.password || "")}" class="pf-c-form-control" required>
<input type="text" value="${ifDefined(this.stage?.password || "")}" class="pf-c-form-control">
</ak-form-element-horizontal>
<ak-form-element-horizontal name="useTls">
<div class="pf-c-check">
@ -92,7 +90,7 @@ export class EmailStageForm extends Form<EmailStage> {
</ak-form-element-horizontal>
<ak-form-element-horizontal name="useSsl">
<div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${first(this.stage?.useSsl, true)}>
<input type="checkbox" class="pf-c-check__input" ?checked=${first(this.stage?.useSsl, false)}>
<label class="pf-c-check__label">
${t`Use SSL`}
</label>