diff --git a/web/src/elements/events/UserEvents.ts b/web/src/elements/events/UserEvents.ts new file mode 100644 index 000000000..62d79ae00 --- /dev/null +++ b/web/src/elements/events/UserEvents.ts @@ -0,0 +1,77 @@ +import { t } from "@lingui/macro"; +import { customElement, html, property, TemplateResult } from "lit-element"; +import { AKResponse } from "../../api/Client"; +import { Table, TableColumn } from "../table/Table"; +import { Event, EventsApi } from "authentik-api"; + +import "../forms/DeleteForm"; +import "../Tabs"; +import "../buttons/ModalButton"; +import "../buttons/SpinnerButton"; +import "../buttons/Dropdown"; +import "../../pages/events/EventInfo"; +import { PAGE_SIZE } from "../../constants"; +import { DEFAULT_CONFIG } from "../../api/Config"; +import { EventWithContext } from "../../api/Events"; + +@customElement("ak-events-user") +export class ObjectChangelog extends Table { + expandable = true; + + @property() + order = "-created"; + + @property() + targetUser!: string; + + apiEndpoint(page: number): Promise> { + return new EventsApi(DEFAULT_CONFIG).eventsEventsList({ + page: page, + ordering: this.order, + pageSize: PAGE_SIZE / 2, + username: this.targetUser + }); + } + + columns(): TableColumn[] { + return [ + new TableColumn(t`Action`, "action"), + new TableColumn(t`User`, "enabled"), + new TableColumn(t`Creation Date`, "created"), + new TableColumn(t`Client IP`, "client_ip"), + ]; + } + + row(item: EventWithContext): TemplateResult[] { + return [ + html`${item.action}`, + html`
${item.user?.username}
+ ${item.user.on_behalf_of ? html` + ${t`On behalf of ${item.user.on_behalf_of.username}`} + ` : html``}`, + html`${item.created?.toLocaleString()}`, + html`${item.clientIp || "-"}`, + ]; + } + + renderExpanded(item: Event): TemplateResult { + return html` + +
+ +
+ + + + `; + } + + renderEmpty(): TemplateResult { + return super.renderEmpty(html` +
+ ${t`No matching events could be found.`} +
+
`); + } + +} diff --git a/web/src/locales/en.po b/web/src/locales/en.po index fc4186093..2329c0fe0 100644 --- a/web/src/locales/en.po +++ b/web/src/locales/en.po @@ -69,6 +69,7 @@ msgid "Access token URL" msgstr "Access token URL" #: src/elements/events/ObjectChangelog.ts:38 +#: src/elements/events/UserEvents.ts:35 #: src/pages/events/EventListPage.ts:43 #: src/pages/policies/event_matcher/EventMatcherPolicyForm.ts:79 msgid "Action" @@ -76,7 +77,7 @@ msgstr "Action" #: src/pages/groups/MemberSelectModal.ts:45 #: src/pages/users/UserListPage.ts:51 -#: src/pages/users/UserViewPage.ts:115 +#: src/pages/users/UserViewPage.ts:116 msgid "Active" msgstr "Active" @@ -469,7 +470,7 @@ msgstr "Change your password" #: src/pages/sources/ldap/LDAPSourceViewPage.ts:113 #: src/pages/sources/oauth/OAuthSourceViewPage.ts:132 #: src/pages/sources/saml/SAMLSourceViewPage.ts:119 -#: src/pages/users/UserViewPage.ts:176 +#: src/pages/users/UserViewPage.ts:185 msgid "Changelog" msgstr "Changelog" @@ -536,6 +537,7 @@ msgid "Client ID" msgstr "Client ID" #: src/elements/events/ObjectChangelog.ts:41 +#: src/elements/events/UserEvents.ts:38 #: src/pages/events/EventListPage.ts:46 #: src/pages/policies/event_matcher/EventMatcherPolicyForm.ts:93 msgid "Client IP" @@ -831,6 +833,7 @@ msgid "Created {0}" msgstr "Created {0}" #: src/elements/events/ObjectChangelog.ts:40 +#: src/elements/events/UserEvents.ts:37 #: src/pages/events/EventListPage.ts:45 msgid "Creation Date" msgstr "Creation Date" @@ -1031,7 +1034,7 @@ msgstr "Each provider has a different issuer, based on the application slug." #: src/pages/stages/prompt/PromptListPage.ts:75 #: src/pages/user-settings/tokens/UserTokenList.ts:113 #: src/pages/users/UserListPage.ts:76 -#: src/pages/users/UserViewPage.ts:146 +#: src/pages/users/UserViewPage.ts:147 msgid "Edit" msgstr "Edit" @@ -1064,7 +1067,7 @@ msgstr "Either no applications are defined, or you don't have access to any." #: src/pages/stages/identification/IdentificationStageForm.ts:82 #: src/pages/user-settings/UserDetailsPage.ts:71 #: src/pages/users/UserForm.ts:61 -#: src/pages/users/UserViewPage.ts:99 +#: src/pages/users/UserViewPage.ts:100 msgid "Email" msgstr "Email" @@ -1224,7 +1227,7 @@ msgstr "Expiry" msgid "Expiry date" msgstr "Expiry date" -#: src/pages/users/UserViewPage.ts:187 +#: src/pages/users/UserViewPage.ts:196 msgid "Explicit Consent" msgstr "Explicit Consent" @@ -1624,7 +1627,7 @@ msgstr "Label shown next to/above the prompt." #: src/pages/groups/MemberSelectModal.ts:46 #: src/pages/users/UserListPage.ts:52 -#: src/pages/users/UserViewPage.ts:107 +#: src/pages/users/UserViewPage.ts:108 msgid "Last login" msgstr "Last login" @@ -1901,7 +1904,7 @@ msgstr "Monitor" #: src/pages/user-settings/UserDetailsPage.ts:64 #: src/pages/users/UserForm.ts:54 #: src/pages/users/UserListPage.ts:50 -#: src/pages/users/UserViewPage.ts:91 +#: src/pages/users/UserViewPage.ts:92 msgid "Name" msgstr "Name" @@ -1944,6 +1947,7 @@ msgid "No Applications available." msgstr "No Applications available." #: src/elements/events/ObjectChangelog.ts:68 +#: src/elements/events/UserEvents.ts:65 msgid "No Events found." msgstr "No Events found." @@ -1972,6 +1976,7 @@ msgid "No form found" msgstr "No form found" #: src/elements/events/ObjectChangelog.ts:70 +#: src/elements/events/UserEvents.ts:67 msgid "No matching events could be found." msgstr "No matching events could be found." @@ -2058,11 +2063,11 @@ msgstr "Notifications Transport" msgid "Number" msgstr "Number" -#: src/pages/users/UserViewPage.ts:195 +#: src/pages/users/UserViewPage.ts:204 msgid "OAuth Authorization Codes" msgstr "OAuth Authorization Codes" -#: src/pages/users/UserViewPage.ts:203 +#: src/pages/users/UserViewPage.ts:212 msgid "OAuth Refresh Codes" msgstr "OAuth Refresh Codes" @@ -2084,6 +2089,7 @@ msgid "Offset after which consent expires. (Format: hours=1;minutes=2;seconds=3) msgstr "Offset after which consent expires. (Format: hours=1;minutes=2;seconds=3)." #: src/elements/events/ObjectChangelog.ts:50 +#: src/elements/events/UserEvents.ts:47 #: src/pages/events/EventListPage.ts:60 msgid "On behalf of {0}" msgstr "On behalf of {0}" @@ -2182,7 +2188,7 @@ msgstr "Outposts are deployments of authentik components to support different en #: src/pages/sources/ldap/LDAPSourceViewPage.ts:56 #: src/pages/sources/oauth/OAuthSourceViewPage.ts:55 #: src/pages/sources/saml/SAMLSourceViewPage.ts:58 -#: src/pages/users/UserViewPage.ts:73 +#: src/pages/users/UserViewPage.ts:74 msgid "Overview" msgstr "Overview" @@ -2520,7 +2526,7 @@ msgid "Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only." msgstr "Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only." #: src/pages/users/UserListPage.ts:133 -#: src/pages/users/UserViewPage.ts:164 +#: src/pages/users/UserViewPage.ts:165 msgid "Reset Password" msgstr "Reset Password" @@ -3047,7 +3053,7 @@ msgid "Successfully generated certificate-key pair." msgstr "Successfully generated certificate-key pair." #: src/pages/users/UserListPage.ts:128 -#: src/pages/users/UserViewPage.ts:159 +#: src/pages/users/UserViewPage.ts:160 msgid "Successfully generated recovery link" msgstr "Successfully generated recovery link" @@ -3178,7 +3184,7 @@ msgstr "Successfully updated user." msgid "Successfully updated {0} {1}" msgstr "Successfully updated {0} {1}" -#: src/pages/users/UserViewPage.ts:125 +#: src/pages/users/UserViewPage.ts:126 msgid "Superuser" msgstr "Superuser" @@ -3473,7 +3479,7 @@ msgstr "Up-to-date!" #: src/pages/user-settings/tokens/UserTokenList.ts:105 #: src/pages/users/UserActiveForm.ts:66 #: src/pages/users/UserListPage.ts:68 -#: src/pages/users/UserViewPage.ts:138 +#: src/pages/users/UserViewPage.ts:139 msgid "Update" msgstr "Update" @@ -3549,7 +3555,7 @@ msgstr "Update Token" #: src/pages/policies/BoundPoliciesList.ts:102 #: src/pages/users/UserListPage.ts:71 -#: src/pages/users/UserViewPage.ts:141 +#: src/pages/users/UserViewPage.ts:142 msgid "Update User" msgstr "Update User" @@ -3590,6 +3596,7 @@ msgid "Use global settings" msgstr "Use global settings" #: src/elements/events/ObjectChangelog.ts:39 +#: src/elements/events/UserEvents.ts:36 #: src/pages/events/EventInfo.ts:83 #: src/pages/events/EventListPage.ts:44 #: src/pages/policies/PolicyBindingForm.ts:140 @@ -3603,7 +3610,7 @@ msgstr "Use global settings" msgid "User" msgstr "User" -#: src/pages/users/UserViewPage.ts:77 +#: src/pages/users/UserViewPage.ts:78 msgid "User Info" msgstr "User Info" @@ -3619,6 +3626,10 @@ msgstr "User Settings" msgid "User details" msgstr "User details" +#: src/pages/users/UserViewPage.ts:177 +msgid "User events" +msgstr "User events" + #: src/pages/stages/authenticator_validate/AuthenticatorValidateStageForm.ts:99 #: src/pages/stages/identification/IdentificationStageForm.ts:74 msgid "User fields" @@ -3633,7 +3644,7 @@ msgid "User password writeback" msgstr "User password writeback" #: src/pages/policies/BoundPoliciesList.ts:52 -#: src/pages/users/UserViewPage.ts:62 +#: src/pages/users/UserViewPage.ts:63 msgid "User {0}" msgstr "User {0}" @@ -3661,7 +3672,7 @@ msgstr "Userinfo URL" #: src/pages/stages/identification/IdentificationStageForm.ts:79 #: src/pages/user-settings/UserDetailsPage.ts:57 #: src/pages/users/UserForm.ts:47 -#: src/pages/users/UserViewPage.ts:83 +#: src/pages/users/UserViewPage.ts:84 msgid "Username" msgstr "Username" diff --git a/web/src/locales/pseudo-LOCALE.po b/web/src/locales/pseudo-LOCALE.po index 164dac6e9..7b2b927ec 100644 --- a/web/src/locales/pseudo-LOCALE.po +++ b/web/src/locales/pseudo-LOCALE.po @@ -69,6 +69,7 @@ msgid "Access token URL" msgstr "" #: src/elements/events/ObjectChangelog.ts:38 +#: src/elements/events/UserEvents.ts:35 #: src/pages/events/EventListPage.ts:43 #: src/pages/policies/event_matcher/EventMatcherPolicyForm.ts:79 msgid "Action" @@ -76,7 +77,7 @@ msgstr "" #: src/pages/groups/MemberSelectModal.ts:45 #: src/pages/users/UserListPage.ts:51 -#: src/pages/users/UserViewPage.ts:115 +#: src/pages/users/UserViewPage.ts:116 msgid "Active" msgstr "" @@ -465,7 +466,7 @@ msgstr "" #: src/pages/sources/ldap/LDAPSourceViewPage.ts:113 #: src/pages/sources/oauth/OAuthSourceViewPage.ts:132 #: src/pages/sources/saml/SAMLSourceViewPage.ts:119 -#: src/pages/users/UserViewPage.ts:176 +#: src/pages/users/UserViewPage.ts:185 msgid "Changelog" msgstr "" @@ -530,6 +531,7 @@ msgid "Client ID" msgstr "" #: src/elements/events/ObjectChangelog.ts:41 +#: src/elements/events/UserEvents.ts:38 #: src/pages/events/EventListPage.ts:46 #: src/pages/policies/event_matcher/EventMatcherPolicyForm.ts:93 msgid "Client IP" @@ -825,6 +827,7 @@ msgid "Created {0}" msgstr "" #: src/elements/events/ObjectChangelog.ts:40 +#: src/elements/events/UserEvents.ts:37 #: src/pages/events/EventListPage.ts:45 msgid "Creation Date" msgstr "" @@ -1023,7 +1026,7 @@ msgstr "" #: src/pages/stages/prompt/PromptListPage.ts:75 #: src/pages/user-settings/tokens/UserTokenList.ts:113 #: src/pages/users/UserListPage.ts:76 -#: src/pages/users/UserViewPage.ts:146 +#: src/pages/users/UserViewPage.ts:147 msgid "Edit" msgstr "" @@ -1056,7 +1059,7 @@ msgstr "" #: src/pages/stages/identification/IdentificationStageForm.ts:82 #: src/pages/user-settings/UserDetailsPage.ts:71 #: src/pages/users/UserForm.ts:61 -#: src/pages/users/UserViewPage.ts:99 +#: src/pages/users/UserViewPage.ts:100 msgid "Email" msgstr "" @@ -1216,7 +1219,7 @@ msgstr "" msgid "Expiry date" msgstr "" -#: src/pages/users/UserViewPage.ts:187 +#: src/pages/users/UserViewPage.ts:196 msgid "Explicit Consent" msgstr "" @@ -1616,7 +1619,7 @@ msgstr "" #: src/pages/groups/MemberSelectModal.ts:46 #: src/pages/users/UserListPage.ts:52 -#: src/pages/users/UserViewPage.ts:107 +#: src/pages/users/UserViewPage.ts:108 msgid "Last login" msgstr "" @@ -1893,7 +1896,7 @@ msgstr "" #: src/pages/user-settings/UserDetailsPage.ts:64 #: src/pages/users/UserForm.ts:54 #: src/pages/users/UserListPage.ts:50 -#: src/pages/users/UserViewPage.ts:91 +#: src/pages/users/UserViewPage.ts:92 msgid "Name" msgstr "" @@ -1936,6 +1939,7 @@ msgid "No Applications available." msgstr "" #: src/elements/events/ObjectChangelog.ts:68 +#: src/elements/events/UserEvents.ts:65 msgid "No Events found." msgstr "" @@ -1964,6 +1968,7 @@ msgid "No form found" msgstr "" #: src/elements/events/ObjectChangelog.ts:70 +#: src/elements/events/UserEvents.ts:67 msgid "No matching events could be found." msgstr "" @@ -2050,11 +2055,11 @@ msgstr "" msgid "Number" msgstr "" -#: src/pages/users/UserViewPage.ts:195 +#: src/pages/users/UserViewPage.ts:204 msgid "OAuth Authorization Codes" msgstr "" -#: src/pages/users/UserViewPage.ts:203 +#: src/pages/users/UserViewPage.ts:212 msgid "OAuth Refresh Codes" msgstr "" @@ -2076,6 +2081,7 @@ msgid "Offset after which consent expires. (Format: hours=1;minutes=2;seconds=3) msgstr "" #: src/elements/events/ObjectChangelog.ts:50 +#: src/elements/events/UserEvents.ts:47 #: src/pages/events/EventListPage.ts:60 msgid "On behalf of {0}" msgstr "" @@ -2174,7 +2180,7 @@ msgstr "" #: src/pages/sources/ldap/LDAPSourceViewPage.ts:56 #: src/pages/sources/oauth/OAuthSourceViewPage.ts:55 #: src/pages/sources/saml/SAMLSourceViewPage.ts:58 -#: src/pages/users/UserViewPage.ts:73 +#: src/pages/users/UserViewPage.ts:74 msgid "Overview" msgstr "" @@ -2512,7 +2518,7 @@ msgid "Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only." msgstr "" #: src/pages/users/UserListPage.ts:133 -#: src/pages/users/UserViewPage.ts:164 +#: src/pages/users/UserViewPage.ts:165 msgid "Reset Password" msgstr "" @@ -3039,7 +3045,7 @@ msgid "Successfully generated certificate-key pair." msgstr "" #: src/pages/users/UserListPage.ts:128 -#: src/pages/users/UserViewPage.ts:159 +#: src/pages/users/UserViewPage.ts:160 msgid "Successfully generated recovery link" msgstr "" @@ -3170,7 +3176,7 @@ msgstr "" msgid "Successfully updated {0} {1}" msgstr "" -#: src/pages/users/UserViewPage.ts:125 +#: src/pages/users/UserViewPage.ts:126 msgid "Superuser" msgstr "" @@ -3463,7 +3469,7 @@ msgstr "" #: src/pages/user-settings/tokens/UserTokenList.ts:105 #: src/pages/users/UserActiveForm.ts:66 #: src/pages/users/UserListPage.ts:68 -#: src/pages/users/UserViewPage.ts:138 +#: src/pages/users/UserViewPage.ts:139 msgid "Update" msgstr "" @@ -3539,7 +3545,7 @@ msgstr "" #: src/pages/policies/BoundPoliciesList.ts:102 #: src/pages/users/UserListPage.ts:71 -#: src/pages/users/UserViewPage.ts:141 +#: src/pages/users/UserViewPage.ts:142 msgid "Update User" msgstr "" @@ -3580,6 +3586,7 @@ msgid "Use global settings" msgstr "" #: src/elements/events/ObjectChangelog.ts:39 +#: src/elements/events/UserEvents.ts:36 #: src/pages/events/EventInfo.ts:83 #: src/pages/events/EventListPage.ts:44 #: src/pages/policies/PolicyBindingForm.ts:140 @@ -3593,7 +3600,7 @@ msgstr "" msgid "User" msgstr "" -#: src/pages/users/UserViewPage.ts:77 +#: src/pages/users/UserViewPage.ts:78 msgid "User Info" msgstr "" @@ -3609,6 +3616,10 @@ msgstr "" msgid "User details" msgstr "" +#: src/pages/users/UserViewPage.ts:177 +msgid "User events" +msgstr "" + #: src/pages/stages/authenticator_validate/AuthenticatorValidateStageForm.ts:99 #: src/pages/stages/identification/IdentificationStageForm.ts:74 msgid "User fields" @@ -3623,7 +3634,7 @@ msgid "User password writeback" msgstr "" #: src/pages/policies/BoundPoliciesList.ts:52 -#: src/pages/users/UserViewPage.ts:62 +#: src/pages/users/UserViewPage.ts:63 msgid "User {0}" msgstr "" @@ -3651,7 +3662,7 @@ msgstr "" #: src/pages/stages/identification/IdentificationStageForm.ts:79 #: src/pages/user-settings/UserDetailsPage.ts:57 #: src/pages/users/UserForm.ts:47 -#: src/pages/users/UserViewPage.ts:83 +#: src/pages/users/UserViewPage.ts:84 msgid "Username" msgstr "" diff --git a/web/src/pages/admin-overview/cards/LDAPSyncStatusCard.ts b/web/src/pages/admin-overview/cards/LDAPSyncStatusCard.ts index 96c915a6e..54073da9d 100644 --- a/web/src/pages/admin-overview/cards/LDAPSyncStatusCard.ts +++ b/web/src/pages/admin-overview/cards/LDAPSyncStatusCard.ts @@ -22,7 +22,7 @@ export class LDAPSyncStatusCard extends AdminStatusCard { } renderValue(): TemplateResult { - return html`${t`Last sync: ${this.value?.taskFinishTimestamp?.toLocaleTimeString()}`}`; + return html`${t`Last sync: ${this.value?.taskFinishTimestamp?.toLocaleTimeString() || "-"}`}`; } getStatus(value: Task): Promise { diff --git a/web/src/pages/users/UserViewPage.ts b/web/src/pages/users/UserViewPage.ts index 82bf1c31c..6155ad2d3 100644 --- a/web/src/pages/users/UserViewPage.ts +++ b/web/src/pages/users/UserViewPage.ts @@ -14,7 +14,6 @@ import PFButton from "@patternfly/patternfly/components/Button/button.css"; import AKGlobal from "../../authentik.css"; import "../../elements/forms/ModalForm"; -import "./UserForm"; import "../../elements/buttons/ActionButton"; import "../../elements/buttons/SpinnerButton"; import "../../elements/CodeMirror"; @@ -25,6 +24,8 @@ import "../../elements/oauth/UserCodeList"; import "../../elements/oauth/UserRefreshList"; import "../../elements/charts/UserChart"; import "../../elements/PageHeader"; +import "../../elements/events/UserEvents"; +import "./UserForm"; import { CoreApi, User } from "authentik-api"; import { DEFAULT_CONFIG } from "../../api/Config"; import { EVENT_REFRESH } from "../../constants"; @@ -75,7 +76,7 @@ export class UserViewPage extends LitElement { return html`
+
+
+
+ + +
+
+