import { t } from "@lingui/macro"; import { html, TemplateResult } from "lit"; import { customElement } from "lit/decorators"; import { ifDefined } from "lit/directives/if-defined"; import { until } from "lit/directives/until"; import { AdminApi, EventMatcherPolicy, EventsApi, PoliciesApi } from "@goauthentik/api"; import { DEFAULT_CONFIG } from "../../../api/Config"; import "../../../elements/forms/FormGroup"; import "../../../elements/forms/HorizontalFormElement"; import { ModelForm } from "../../../elements/forms/ModelForm"; import { first } from "../../../utils"; @customElement("ak-policy-event-matcher-form") export class EventMatcherPolicyForm extends ModelForm { loadInstance(pk: string): Promise { return new PoliciesApi(DEFAULT_CONFIG).policiesEventMatcherRetrieve({ policyUuid: pk, }); } getSuccessMessage(): string { if (this.instance) { return t`Successfully updated policy.`; } else { return t`Successfully created policy.`; } } send = (data: EventMatcherPolicy): Promise => { if (this.instance) { return new PoliciesApi(DEFAULT_CONFIG).policiesEventMatcherUpdate({ policyUuid: this.instance.pk || "", eventMatcherPolicyRequest: data, }); } else { return new PoliciesApi(DEFAULT_CONFIG).policiesEventMatcherCreate({ eventMatcherPolicyRequest: data, }); } }; renderForm(): TemplateResult { return html` ${t`Matches an event against a set of criteria. If any of the configured values match, the policy passes.`} ${t`Execution logging`} ${t`When this option is enabled, all executions of this policy will be logged. By default, only execution errors are logged.`} ${t`Policy-specific settings`} --------- ${until( new EventsApi(DEFAULT_CONFIG) .eventsEventsActionsList() .then((actions) => { return actions.map((action) => { return html` ${action.name} `; }); }), html`${t`Loading...`}`, )} ${t`Match created events with this action type. When left empty, all action types will be matched.`} ${t`Matches Event's Client IP (strict matching, for network matching use an Expression Policy.`} --------- ${until( new AdminApi(DEFAULT_CONFIG).adminAppsList().then((apps) => { return apps.map((app) => { return html` ${app.label} `; }); }), html`${t`Loading...`}`, )} ${t`Match events created by selected application. When left empty, all applications are matched.`} `; } }
${t`When this option is enabled, all executions of this policy will be logged. By default, only execution errors are logged.`}
${t`Match created events with this action type. When left empty, all action types will be matched.`}
${t`Matches Event's Client IP (strict matching, for network matching use an Expression Policy.`}
${t`Match events created by selected application. When left empty, all applications are matched.`}