diff --git a/authentik/core/expression.py b/authentik/core/expression.py index bcec7a227..220e37b13 100644 --- a/authentik/core/expression.py +++ b/authentik/core/expression.py @@ -28,7 +28,7 @@ class PropertyMappingEvaluator(BaseEvaluator): event = Event.new( EventAction.PROPERTY_MAPPING_EXCEPTION, expression=expression_source, - error=error_string, + message=error_string, ) if "user" in self._context: event.set_user(self._context["user"]) diff --git a/authentik/policies/process.py b/authentik/policies/process.py index 88a98116f..0f2f2e798 100644 --- a/authentik/policies/process.py +++ b/authentik/policies/process.py @@ -48,12 +48,13 @@ class PolicyProcess(Process): if connection: self.connection = connection - def create_event(self, action: str, **kwargs): + def create_event(self, action: str, message: str, **kwargs): """Create event with common values from `self.request` and `self.binding`.""" # Keep a reference to http_request even if its None, because cleanse_dict will remove it http_request = self.request.http_request event = Event.new( action=action, + message=message, policy_uuid=self.binding.policy.policy_uuid.hex, binding=self.binding, request=self.request, @@ -76,7 +77,11 @@ class PolicyProcess(Process): try: policy_result = self.binding.policy.passes(self.request) if self.binding.policy.execution_logging: - self.create_event(EventAction.POLICY_EXECUTION, message="Policy Execution", result=policy_result) + self.create_event( + EventAction.POLICY_EXECUTION, + message="Policy Execution", + result=policy_result, + ) except PolicyException as exc: # Create policy exception event error_string = "".join(format_tb(exc.__traceback__)) + str(exc) diff --git a/web/src/api/EventNotification.ts b/web/src/api/EventNotification.ts index a33af27a5..a8dac67f3 100644 --- a/web/src/api/EventNotification.ts +++ b/web/src/api/EventNotification.ts @@ -1,25 +1,24 @@ import { DefaultClient, QueryArguments, PBResponse } from "./Client"; +import { Event } from "./Events"; export class Notification { pk: string; - name: string; - mode: string; - mode_verbose: string; - webhook_url: string; + severity: string; + body: string; + created: string; + event?: Event; + seen: boolean; constructor() { throw Error(); } - static get(pk: string): Promise { - return DefaultClient.fetch(["events", "transports", pk]); + static get(pk: string): Promise { + return DefaultClient.fetch(["events", "notifications", pk]); } - static list(filter?: QueryArguments): Promise> { - return DefaultClient.fetch>(["events", "transports"], filter); + static list(filter?: QueryArguments): Promise> { + return DefaultClient.fetch>(["events", "notifications"], filter); } - static adminUrl(rest: string): string { - return `/administration/events/transports/${rest}`; - } } diff --git a/web/src/elements/sidebar/SidebarUser.ts b/web/src/elements/sidebar/SidebarUser.ts index 494ea9c83..1e200ad73 100644 --- a/web/src/elements/sidebar/SidebarUser.ts +++ b/web/src/elements/sidebar/SidebarUser.ts @@ -1,4 +1,4 @@ -import { css, CSSResult, customElement, html, LitElement, TemplateResult } from "lit-element"; +import { css, CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element"; // @ts-ignore import NavStyle from "@patternfly/patternfly/components/Nav/nav.css"; // @ts-ignore @@ -8,8 +8,11 @@ import AvatarStyle from "@patternfly/patternfly/components/Avatar/avatar.css"; import { User } from "../../api/Users"; import { until } from "lit-html/directives/until"; +import "../notifications/NotificationTrigger"; + @customElement("ak-sidebar-user") export class SidebarUser extends LitElement { + static get styles(): CSSResult[] { return [ fa, @@ -24,19 +27,8 @@ export class SidebarUser extends LitElement { } .pf-c-nav__link { align-items: center; - } - .user-avatar { display: flex; - flex-direction: row; - } - .user-avatar > span { - line-height: var(--pf-c-avatar--Height); - padding-left: var(--pf-global--spacer--sm); - font-size: var(--pf-global--FontSize--lg); - } - .user-logout { - flex-shrink: 3; - max-width: 75px; + justify-content: center; } `, ]; @@ -46,10 +38,11 @@ export class SidebarUser extends LitElement { return html` ${until(User.me().then(u => { - return html` - ${u.name}`; - }), html``)} + return html``;}), html``)} + + + diff --git a/web/src/interfaces/Interface.ts b/web/src/interfaces/Interface.ts index aac203f8b..b41fd8e45 100644 --- a/web/src/interfaces/Interface.ts +++ b/web/src/interfaces/Interface.ts @@ -5,11 +5,15 @@ import { SidebarItem } from "../elements/sidebar/Sidebar"; import "../elements/router/RouterOutlet"; import "../elements/messages/MessageContainer"; import "../elements/sidebar/SidebarHamburger"; +import "../elements/notifications/NotificationDrawer" export abstract class Interface extends LitElement { @property({type: Boolean}) sidebarOpen = true; + @property({type: Boolean}) + notificationOpen = false; + abstract get sidebar(): SidebarItem[]; createRenderRoot(): ShadowRoot | Element { @@ -25,6 +29,9 @@ export abstract class Interface extends LitElement { window.addEventListener("ak-sidebar-toggle", () => { this.sidebarOpen = !this.sidebarOpen; }); + window.addEventListener("ak-notification-toggle", () => { + this.notificationOpen = !this.notificationOpen; + }); } render(): TemplateResult { @@ -35,10 +42,22 @@ export abstract class Interface extends LitElement { -
- - -
+
+
+
+
+
+
+ + +
+
+
+ + +
+
+
`; } diff --git a/web/src/pages/events/EventInfo.ts b/web/src/pages/events/EventInfo.ts index f172846bc..3385c82e5 100644 --- a/web/src/pages/events/EventInfo.ts +++ b/web/src/pages/events/EventInfo.ts @@ -95,7 +95,7 @@ export class EventInfo extends LitElement { return html`

${gettext("Exception")}

- ${this.event.context.error || this.event.context.message} + ${this.event.context.message || this.event.context.error}

${gettext("Expression")}

@@ -117,7 +117,7 @@ export class EventInfo extends LitElement {

${gettext("Exception")}

- ${this.event.context.error} + ${this.event.context.message || this.event.context.error}
`; case "policy_execution":