web/admin: migrate policy forms
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
c99afe0ad4
commit
ce1c400022
|
@ -1,31 +1,26 @@
|
||||||
import { AdminApi, EventMatcherPolicy, EventsApi, PoliciesApi } from "authentik-api";
|
import { AdminApi, EventMatcherPolicy, EventsApi, PoliciesApi } from "authentik-api";
|
||||||
import { t } from "@lingui/macro";
|
import { t } from "@lingui/macro";
|
||||||
import { customElement, property } from "lit-element";
|
import { customElement } from "lit-element";
|
||||||
import { html, TemplateResult } from "lit-html";
|
import { html, TemplateResult } from "lit-html";
|
||||||
import { DEFAULT_CONFIG } from "../../../api/Config";
|
import { DEFAULT_CONFIG } from "../../../api/Config";
|
||||||
import { Form } from "../../../elements/forms/Form";
|
|
||||||
import { ifDefined } from "lit-html/directives/if-defined";
|
import { ifDefined } from "lit-html/directives/if-defined";
|
||||||
import "../../../elements/forms/HorizontalFormElement";
|
import "../../../elements/forms/HorizontalFormElement";
|
||||||
import "../../../elements/forms/FormGroup";
|
import "../../../elements/forms/FormGroup";
|
||||||
import { until } from "lit-html/directives/until";
|
import { until } from "lit-html/directives/until";
|
||||||
import { first } from "../../../utils";
|
import { first } from "../../../utils";
|
||||||
|
import { ModelForm } from "../../../elements/forms/ModelForm";
|
||||||
|
|
||||||
@customElement("ak-policy-event-matcher-form")
|
@customElement("ak-policy-event-matcher-form")
|
||||||
export class EventMatcherPolicyForm extends Form<EventMatcherPolicy> {
|
export class EventMatcherPolicyForm extends ModelForm<EventMatcherPolicy, string> {
|
||||||
|
|
||||||
set policyUUID(value: string) {
|
loadInstance(pk: string): Promise<EventMatcherPolicy> {
|
||||||
new PoliciesApi(DEFAULT_CONFIG).policiesEventMatcherRead({
|
return new PoliciesApi(DEFAULT_CONFIG).policiesEventMatcherRead({
|
||||||
policyUuid: value,
|
policyUuid: pk,
|
||||||
}).then(policy => {
|
|
||||||
this.policy = policy;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@property({attribute: false})
|
|
||||||
policy?: EventMatcherPolicy;
|
|
||||||
|
|
||||||
getSuccessMessage(): string {
|
getSuccessMessage(): string {
|
||||||
if (this.policy) {
|
if (this.instance) {
|
||||||
return t`Successfully updated policy.`;
|
return t`Successfully updated policy.`;
|
||||||
} else {
|
} else {
|
||||||
return t`Successfully created policy.`;
|
return t`Successfully created policy.`;
|
||||||
|
@ -33,9 +28,9 @@ export class EventMatcherPolicyForm extends Form<EventMatcherPolicy> {
|
||||||
}
|
}
|
||||||
|
|
||||||
send = (data: EventMatcherPolicy): Promise<EventMatcherPolicy> => {
|
send = (data: EventMatcherPolicy): Promise<EventMatcherPolicy> => {
|
||||||
if (this.policy) {
|
if (this.instance) {
|
||||||
return new PoliciesApi(DEFAULT_CONFIG).policiesEventMatcherUpdate({
|
return new PoliciesApi(DEFAULT_CONFIG).policiesEventMatcherUpdate({
|
||||||
policyUuid: this.policy.pk || "",
|
policyUuid: this.instance.pk || "",
|
||||||
data: data
|
data: data
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -54,11 +49,11 @@ export class EventMatcherPolicyForm extends Form<EventMatcherPolicy> {
|
||||||
label=${t`Name`}
|
label=${t`Name`}
|
||||||
?required=${true}
|
?required=${true}
|
||||||
name="name">
|
name="name">
|
||||||
<input type="text" value="${ifDefined(this.policy?.name || "")}" class="pf-c-form-control" required>
|
<input type="text" value="${ifDefined(this.instance?.name || "")}" class="pf-c-form-control" required>
|
||||||
</ak-form-element-horizontal>
|
</ak-form-element-horizontal>
|
||||||
<ak-form-element-horizontal name="executionLogging">
|
<ak-form-element-horizontal name="executionLogging">
|
||||||
<div class="pf-c-check">
|
<div class="pf-c-check">
|
||||||
<input type="checkbox" class="pf-c-check__input" ?checked=${first(this.policy?.executionLogging, false)}>
|
<input type="checkbox" class="pf-c-check__input" ?checked=${first(this.instance?.executionLogging, false)}>
|
||||||
<label class="pf-c-check__label">
|
<label class="pf-c-check__label">
|
||||||
${t`Execution logging`}
|
${t`Execution logging`}
|
||||||
</label>
|
</label>
|
||||||
|
@ -76,10 +71,10 @@ export class EventMatcherPolicyForm extends Form<EventMatcherPolicy> {
|
||||||
label=${t`Action`}
|
label=${t`Action`}
|
||||||
name="action">
|
name="action">
|
||||||
<select class="pf-c-form-control">
|
<select class="pf-c-form-control">
|
||||||
<option value="" ?selected=${this.policy?.action === undefined}>---------</option>
|
<option value="" ?selected=${this.instance?.action === undefined}>---------</option>
|
||||||
${until(new EventsApi(DEFAULT_CONFIG).eventsEventsActions().then(actions => {
|
${until(new EventsApi(DEFAULT_CONFIG).eventsEventsActions().then(actions => {
|
||||||
return actions.map(action => {
|
return actions.map(action => {
|
||||||
return html`<option value=${action.component} ?selected=${this.policy?.action === action.component}>${action.name}</option>`;
|
return html`<option value=${action.component} ?selected=${this.instance?.action === action.component}>${action.name}</option>`;
|
||||||
});
|
});
|
||||||
}), html`<option>${t`Loading...`}</option>`)}
|
}), html`<option>${t`Loading...`}</option>`)}
|
||||||
</select>
|
</select>
|
||||||
|
@ -88,17 +83,17 @@ export class EventMatcherPolicyForm extends Form<EventMatcherPolicy> {
|
||||||
<ak-form-element-horizontal
|
<ak-form-element-horizontal
|
||||||
label=${t`Client IP`}
|
label=${t`Client IP`}
|
||||||
name="clientIp">
|
name="clientIp">
|
||||||
<input type="text" value="${ifDefined(this.policy?.clientIp || "")}" class="pf-c-form-control">
|
<input type="text" value="${ifDefined(this.instance?.clientIp || "")}" class="pf-c-form-control">
|
||||||
<p class="pf-c-form__helper-text">${t`Matches Event's Client IP (strict matching, for network matching use an Expression Policy.`}</p>
|
<p class="pf-c-form__helper-text">${t`Matches Event's Client IP (strict matching, for network matching use an Expression Policy.`}</p>
|
||||||
</ak-form-element-horizontal>
|
</ak-form-element-horizontal>
|
||||||
<ak-form-element-horizontal
|
<ak-form-element-horizontal
|
||||||
label=${t`App`}
|
label=${t`App`}
|
||||||
name="app">
|
name="app">
|
||||||
<select class="pf-c-form-control">
|
<select class="pf-c-form-control">
|
||||||
<option value="" ?selected=${this.policy?.app === undefined}>---------</option>
|
<option value="" ?selected=${this.instance?.app === undefined}>---------</option>
|
||||||
${until(new AdminApi(DEFAULT_CONFIG).adminAppsList().then(apps => {
|
${until(new AdminApi(DEFAULT_CONFIG).adminAppsList().then(apps => {
|
||||||
return apps.map(app => {
|
return apps.map(app => {
|
||||||
return html`<option value=${app.name} ?selected=${this.policy?.app === app.name}>${app.label}</option>`;
|
return html`<option value=${app.name} ?selected=${this.instance?.app === app.name}>${app.label}</option>`;
|
||||||
});
|
});
|
||||||
}), html`<option>${t`Loading...`}</option>`)}
|
}), html`<option>${t`Loading...`}</option>`)}
|
||||||
</select>
|
</select>
|
||||||
|
|
|
@ -1,30 +1,25 @@
|
||||||
import { PasswordExpiryPolicy, PoliciesApi } from "authentik-api";
|
import { PasswordExpiryPolicy, PoliciesApi } from "authentik-api";
|
||||||
import { t } from "@lingui/macro";
|
import { t } from "@lingui/macro";
|
||||||
import { customElement, property } from "lit-element";
|
import { customElement } from "lit-element";
|
||||||
import { html, TemplateResult } from "lit-html";
|
import { html, TemplateResult } from "lit-html";
|
||||||
import { DEFAULT_CONFIG } from "../../../api/Config";
|
import { DEFAULT_CONFIG } from "../../../api/Config";
|
||||||
import { Form } from "../../../elements/forms/Form";
|
|
||||||
import { ifDefined } from "lit-html/directives/if-defined";
|
import { ifDefined } from "lit-html/directives/if-defined";
|
||||||
import "../../../elements/forms/HorizontalFormElement";
|
import "../../../elements/forms/HorizontalFormElement";
|
||||||
import "../../../elements/forms/FormGroup";
|
import "../../../elements/forms/FormGroup";
|
||||||
import { first } from "../../../utils";
|
import { first } from "../../../utils";
|
||||||
|
import { ModelForm } from "../../../elements/forms/ModelForm";
|
||||||
|
|
||||||
@customElement("ak-policy-password-expiry-form")
|
@customElement("ak-policy-password-expiry-form")
|
||||||
export class PasswordExpiryPolicyForm extends Form<PasswordExpiryPolicy> {
|
export class PasswordExpiryPolicyForm extends ModelForm<PasswordExpiryPolicy, string> {
|
||||||
|
|
||||||
set policyUUID(value: string) {
|
loadInstance(pk: string): Promise<PasswordExpiryPolicy> {
|
||||||
new PoliciesApi(DEFAULT_CONFIG).policiesPasswordExpiryRead({
|
return new PoliciesApi(DEFAULT_CONFIG).policiesPasswordExpiryRead({
|
||||||
policyUuid: value,
|
policyUuid: pk,
|
||||||
}).then(policy => {
|
|
||||||
this.policy = policy;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@property({attribute: false})
|
|
||||||
policy?: PasswordExpiryPolicy;
|
|
||||||
|
|
||||||
getSuccessMessage(): string {
|
getSuccessMessage(): string {
|
||||||
if (this.policy) {
|
if (this.instance) {
|
||||||
return t`Successfully updated policy.`;
|
return t`Successfully updated policy.`;
|
||||||
} else {
|
} else {
|
||||||
return t`Successfully created policy.`;
|
return t`Successfully created policy.`;
|
||||||
|
@ -32,9 +27,9 @@ export class PasswordExpiryPolicyForm extends Form<PasswordExpiryPolicy> {
|
||||||
}
|
}
|
||||||
|
|
||||||
send = (data: PasswordExpiryPolicy): Promise<PasswordExpiryPolicy> => {
|
send = (data: PasswordExpiryPolicy): Promise<PasswordExpiryPolicy> => {
|
||||||
if (this.policy) {
|
if (this.instance) {
|
||||||
return new PoliciesApi(DEFAULT_CONFIG).policiesPasswordExpiryUpdate({
|
return new PoliciesApi(DEFAULT_CONFIG).policiesPasswordExpiryUpdate({
|
||||||
policyUuid: this.policy.pk || "",
|
policyUuid: this.instance.pk || "",
|
||||||
data: data
|
data: data
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -53,11 +48,11 @@ export class PasswordExpiryPolicyForm extends Form<PasswordExpiryPolicy> {
|
||||||
label=${t`Name`}
|
label=${t`Name`}
|
||||||
?required=${true}
|
?required=${true}
|
||||||
name="name">
|
name="name">
|
||||||
<input type="text" value="${ifDefined(this.policy?.name || "")}" class="pf-c-form-control" required>
|
<input type="text" value="${ifDefined(this.instance?.name || "")}" class="pf-c-form-control" required>
|
||||||
</ak-form-element-horizontal>
|
</ak-form-element-horizontal>
|
||||||
<ak-form-element-horizontal name="executionLogging">
|
<ak-form-element-horizontal name="executionLogging">
|
||||||
<div class="pf-c-check">
|
<div class="pf-c-check">
|
||||||
<input type="checkbox" class="pf-c-check__input" ?checked=${first(this.policy?.executionLogging, false)}>
|
<input type="checkbox" class="pf-c-check__input" ?checked=${first(this.instance?.executionLogging, false)}>
|
||||||
<label class="pf-c-check__label">
|
<label class="pf-c-check__label">
|
||||||
${t`Execution logging`}
|
${t`Execution logging`}
|
||||||
</label>
|
</label>
|
||||||
|
@ -75,11 +70,11 @@ export class PasswordExpiryPolicyForm extends Form<PasswordExpiryPolicy> {
|
||||||
label=${t`Maximum age (in days)`}
|
label=${t`Maximum age (in days)`}
|
||||||
?required=${true}
|
?required=${true}
|
||||||
name="days">
|
name="days">
|
||||||
<input type="number" value="${ifDefined(this.policy?.days || "")}" class="pf-c-form-control" required>
|
<input type="number" value="${ifDefined(this.instance?.days || "")}" class="pf-c-form-control" required>
|
||||||
</ak-form-element-horizontal>
|
</ak-form-element-horizontal>
|
||||||
<ak-form-element-horizontal name="denyOnly">
|
<ak-form-element-horizontal name="denyOnly">
|
||||||
<div class="pf-c-check">
|
<div class="pf-c-check">
|
||||||
<input type="checkbox" class="pf-c-check__input" ?checked=${first(this.policy?.denyOnly, false)}>
|
<input type="checkbox" class="pf-c-check__input" ?checked=${first(this.instance?.denyOnly, false)}>
|
||||||
<label class="pf-c-check__label">
|
<label class="pf-c-check__label">
|
||||||
${t`Only fail the policy, don't invalidate user's password.`}
|
${t`Only fail the policy, don't invalidate user's password.`}
|
||||||
</label>
|
</label>
|
||||||
|
|
|
@ -1,31 +1,26 @@
|
||||||
import { ExpressionPolicy, PoliciesApi } from "authentik-api";
|
import { ExpressionPolicy, PoliciesApi } from "authentik-api";
|
||||||
import { t } from "@lingui/macro";
|
import { t } from "@lingui/macro";
|
||||||
import { customElement, property } from "lit-element";
|
import { customElement } from "lit-element";
|
||||||
import { html, TemplateResult } from "lit-html";
|
import { html, TemplateResult } from "lit-html";
|
||||||
import { DEFAULT_CONFIG } from "../../../api/Config";
|
import { DEFAULT_CONFIG } from "../../../api/Config";
|
||||||
import { Form } from "../../../elements/forms/Form";
|
|
||||||
import { ifDefined } from "lit-html/directives/if-defined";
|
import { ifDefined } from "lit-html/directives/if-defined";
|
||||||
import "../../../elements/forms/HorizontalFormElement";
|
import "../../../elements/forms/HorizontalFormElement";
|
||||||
import "../../../elements/forms/FormGroup";
|
import "../../../elements/forms/FormGroup";
|
||||||
import "../../../elements/CodeMirror";
|
import "../../../elements/CodeMirror";
|
||||||
import { first } from "../../../utils";
|
import { first } from "../../../utils";
|
||||||
|
import { ModelForm } from "../../../elements/forms/ModelForm";
|
||||||
|
|
||||||
@customElement("ak-policy-expression-form")
|
@customElement("ak-policy-expression-form")
|
||||||
export class ExpressionPolicyForm extends Form<ExpressionPolicy> {
|
export class ExpressionPolicyForm extends ModelForm<ExpressionPolicy, string> {
|
||||||
|
|
||||||
set policyUUID(value: string) {
|
loadInstance(pk: string): Promise<ExpressionPolicy> {
|
||||||
new PoliciesApi(DEFAULT_CONFIG).policiesExpressionRead({
|
return new PoliciesApi(DEFAULT_CONFIG).policiesExpressionRead({
|
||||||
policyUuid: value,
|
policyUuid: pk,
|
||||||
}).then(policy => {
|
|
||||||
this.policy = policy;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@property({attribute: false})
|
|
||||||
policy?: ExpressionPolicy;
|
|
||||||
|
|
||||||
getSuccessMessage(): string {
|
getSuccessMessage(): string {
|
||||||
if (this.policy) {
|
if (this.instance) {
|
||||||
return t`Successfully updated policy.`;
|
return t`Successfully updated policy.`;
|
||||||
} else {
|
} else {
|
||||||
return t`Successfully created policy.`;
|
return t`Successfully created policy.`;
|
||||||
|
@ -33,9 +28,9 @@ export class ExpressionPolicyForm extends Form<ExpressionPolicy> {
|
||||||
}
|
}
|
||||||
|
|
||||||
send = (data: ExpressionPolicy): Promise<ExpressionPolicy> => {
|
send = (data: ExpressionPolicy): Promise<ExpressionPolicy> => {
|
||||||
if (this.policy) {
|
if (this.instance) {
|
||||||
return new PoliciesApi(DEFAULT_CONFIG).policiesExpressionUpdate({
|
return new PoliciesApi(DEFAULT_CONFIG).policiesExpressionUpdate({
|
||||||
policyUuid: this.policy.pk || "",
|
policyUuid: this.instance.pk || "",
|
||||||
data: data
|
data: data
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -54,11 +49,11 @@ export class ExpressionPolicyForm extends Form<ExpressionPolicy> {
|
||||||
label=${t`Name`}
|
label=${t`Name`}
|
||||||
?required=${true}
|
?required=${true}
|
||||||
name="name">
|
name="name">
|
||||||
<input type="text" value="${ifDefined(this.policy?.name || "")}" class="pf-c-form-control" required>
|
<input type="text" value="${ifDefined(this.instance?.name || "")}" class="pf-c-form-control" required>
|
||||||
</ak-form-element-horizontal>
|
</ak-form-element-horizontal>
|
||||||
<ak-form-element-horizontal name="executionLogging">
|
<ak-form-element-horizontal name="executionLogging">
|
||||||
<div class="pf-c-check">
|
<div class="pf-c-check">
|
||||||
<input type="checkbox" class="pf-c-check__input" ?checked=${first(this.policy?.executionLogging, false)}>
|
<input type="checkbox" class="pf-c-check__input" ?checked=${first(this.instance?.executionLogging, false)}>
|
||||||
<label class="pf-c-check__label">
|
<label class="pf-c-check__label">
|
||||||
${t`Execution logging`}
|
${t`Execution logging`}
|
||||||
</label>
|
</label>
|
||||||
|
@ -76,7 +71,7 @@ export class ExpressionPolicyForm extends Form<ExpressionPolicy> {
|
||||||
label=${t`Expression`}
|
label=${t`Expression`}
|
||||||
?required=${true}
|
?required=${true}
|
||||||
name="expression">
|
name="expression">
|
||||||
<ak-codemirror mode="python" value="${ifDefined(this.policy?.expression)}">
|
<ak-codemirror mode="python" value="${ifDefined(this.instance?.expression)}">
|
||||||
</ak-codemirror>
|
</ak-codemirror>
|
||||||
<p class="pf-c-form__helper-text">
|
<p class="pf-c-form__helper-text">
|
||||||
${t`Expression using Python.`}
|
${t`Expression using Python.`}
|
||||||
|
|
|
@ -1,30 +1,25 @@
|
||||||
import { HaveIBeenPwendPolicy, PoliciesApi } from "authentik-api";
|
import { HaveIBeenPwendPolicy, PoliciesApi } from "authentik-api";
|
||||||
import { t } from "@lingui/macro";
|
import { t } from "@lingui/macro";
|
||||||
import { customElement, property } from "lit-element";
|
import { customElement } from "lit-element";
|
||||||
import { html, TemplateResult } from "lit-html";
|
import { html, TemplateResult } from "lit-html";
|
||||||
import { DEFAULT_CONFIG } from "../../../api/Config";
|
import { DEFAULT_CONFIG } from "../../../api/Config";
|
||||||
import { Form } from "../../../elements/forms/Form";
|
|
||||||
import { ifDefined } from "lit-html/directives/if-defined";
|
import { ifDefined } from "lit-html/directives/if-defined";
|
||||||
import "../../../elements/forms/HorizontalFormElement";
|
import "../../../elements/forms/HorizontalFormElement";
|
||||||
import "../../../elements/forms/FormGroup";
|
import "../../../elements/forms/FormGroup";
|
||||||
import { first } from "../../../utils";
|
import { first } from "../../../utils";
|
||||||
|
import { ModelForm } from "../../../elements/forms/ModelForm";
|
||||||
|
|
||||||
@customElement("ak-policy-hibp-form")
|
@customElement("ak-policy-hibp-form")
|
||||||
export class HaveIBeenPwnedPolicyForm extends Form<HaveIBeenPwendPolicy> {
|
export class HaveIBeenPwnedPolicyForm extends ModelForm<HaveIBeenPwendPolicy, string> {
|
||||||
|
|
||||||
set policyUUID(value: string) {
|
loadInstance(pk: string): Promise<HaveIBeenPwendPolicy> {
|
||||||
new PoliciesApi(DEFAULT_CONFIG).policiesHaveibeenpwnedRead({
|
return new PoliciesApi(DEFAULT_CONFIG).policiesHaveibeenpwnedRead({
|
||||||
policyUuid: value,
|
policyUuid: pk,
|
||||||
}).then(policy => {
|
|
||||||
this.policy = policy;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@property({attribute: false})
|
|
||||||
policy?: HaveIBeenPwendPolicy;
|
|
||||||
|
|
||||||
getSuccessMessage(): string {
|
getSuccessMessage(): string {
|
||||||
if (this.policy) {
|
if (this.instance) {
|
||||||
return t`Successfully updated policy.`;
|
return t`Successfully updated policy.`;
|
||||||
} else {
|
} else {
|
||||||
return t`Successfully created policy.`;
|
return t`Successfully created policy.`;
|
||||||
|
@ -32,9 +27,9 @@ export class HaveIBeenPwnedPolicyForm extends Form<HaveIBeenPwendPolicy> {
|
||||||
}
|
}
|
||||||
|
|
||||||
send = (data: HaveIBeenPwendPolicy): Promise<HaveIBeenPwendPolicy> => {
|
send = (data: HaveIBeenPwendPolicy): Promise<HaveIBeenPwendPolicy> => {
|
||||||
if (this.policy) {
|
if (this.instance) {
|
||||||
return new PoliciesApi(DEFAULT_CONFIG).policiesHaveibeenpwnedUpdate({
|
return new PoliciesApi(DEFAULT_CONFIG).policiesHaveibeenpwnedUpdate({
|
||||||
policyUuid: this.policy.pk || "",
|
policyUuid: this.instance.pk || "",
|
||||||
data: data
|
data: data
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -54,11 +49,11 @@ export class HaveIBeenPwnedPolicyForm extends Form<HaveIBeenPwendPolicy> {
|
||||||
label=${t`Name`}
|
label=${t`Name`}
|
||||||
?required=${true}
|
?required=${true}
|
||||||
name="name">
|
name="name">
|
||||||
<input type="text" value="${ifDefined(this.policy?.name || "")}" class="pf-c-form-control" required>
|
<input type="text" value="${ifDefined(this.instance?.name || "")}" class="pf-c-form-control" required>
|
||||||
</ak-form-element-horizontal>
|
</ak-form-element-horizontal>
|
||||||
<ak-form-element-horizontal name="executionLogging">
|
<ak-form-element-horizontal name="executionLogging">
|
||||||
<div class="pf-c-check">
|
<div class="pf-c-check">
|
||||||
<input type="checkbox" class="pf-c-check__input" ?checked=${first(this.policy?.executionLogging, false)}>
|
<input type="checkbox" class="pf-c-check__input" ?checked=${first(this.instance?.executionLogging, false)}>
|
||||||
<label class="pf-c-check__label">
|
<label class="pf-c-check__label">
|
||||||
${t`Execution logging`}
|
${t`Execution logging`}
|
||||||
</label>
|
</label>
|
||||||
|
@ -76,14 +71,14 @@ export class HaveIBeenPwnedPolicyForm extends Form<HaveIBeenPwendPolicy> {
|
||||||
label=${t`Password field`}
|
label=${t`Password field`}
|
||||||
?required=${true}
|
?required=${true}
|
||||||
name="passwordField">
|
name="passwordField">
|
||||||
<input type="text" value="${ifDefined(this.policy?.passwordField || "password")}" class="pf-c-form-control" required>
|
<input type="text" value="${ifDefined(this.instance?.passwordField || "password")}" class="pf-c-form-control" required>
|
||||||
<p class="pf-c-form__helper-text">${t`Field key to check, field keys defined in Prompt stages are available.`}</p>
|
<p class="pf-c-form__helper-text">${t`Field key to check, field keys defined in Prompt stages are available.`}</p>
|
||||||
</ak-form-element-horizontal>
|
</ak-form-element-horizontal>
|
||||||
<ak-form-element-horizontal
|
<ak-form-element-horizontal
|
||||||
label=${t`Allowed count`}
|
label=${t`Allowed count`}
|
||||||
?required=${true}
|
?required=${true}
|
||||||
name="allowedCount">
|
name="allowedCount">
|
||||||
<input type="number" value="${first(this.policy?.allowedCount, 0)}" class="pf-c-form-control" required>
|
<input type="number" value="${first(this.instance?.allowedCount, 0)}" class="pf-c-form-control" required>
|
||||||
<p class="pf-c-form__helper-text">${t`Allow up to N occurrences in the HIBP database.`}</p>
|
<p class="pf-c-form__helper-text">${t`Allow up to N occurrences in the HIBP database.`}</p>
|
||||||
</ak-form-element-horizontal>
|
</ak-form-element-horizontal>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,30 +1,25 @@
|
||||||
import { PasswordPolicy, PoliciesApi } from "authentik-api";
|
import { PasswordPolicy, PoliciesApi } from "authentik-api";
|
||||||
import { t } from "@lingui/macro";
|
import { t } from "@lingui/macro";
|
||||||
import { customElement, property } from "lit-element";
|
import { customElement } from "lit-element";
|
||||||
import { html, TemplateResult } from "lit-html";
|
import { html, TemplateResult } from "lit-html";
|
||||||
import { DEFAULT_CONFIG } from "../../../api/Config";
|
import { DEFAULT_CONFIG } from "../../../api/Config";
|
||||||
import { Form } from "../../../elements/forms/Form";
|
|
||||||
import { ifDefined } from "lit-html/directives/if-defined";
|
import { ifDefined } from "lit-html/directives/if-defined";
|
||||||
import "../../../elements/forms/HorizontalFormElement";
|
import "../../../elements/forms/HorizontalFormElement";
|
||||||
import "../../../elements/forms/FormGroup";
|
import "../../../elements/forms/FormGroup";
|
||||||
import { first } from "../../../utils";
|
import { first } from "../../../utils";
|
||||||
|
import { ModelForm } from "../../../elements/forms/ModelForm";
|
||||||
|
|
||||||
@customElement("ak-policy-password-form")
|
@customElement("ak-policy-password-form")
|
||||||
export class PasswordPolicyForm extends Form<PasswordPolicy> {
|
export class PasswordPolicyForm extends ModelForm<PasswordPolicy, string> {
|
||||||
|
|
||||||
set policyUUID(value: string) {
|
loadInstance(pk: string): Promise<PasswordPolicy> {
|
||||||
new PoliciesApi(DEFAULT_CONFIG).policiesPasswordRead({
|
return new PoliciesApi(DEFAULT_CONFIG).policiesPasswordRead({
|
||||||
policyUuid: value,
|
policyUuid: pk,
|
||||||
}).then(policy => {
|
|
||||||
this.policy = policy;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@property({attribute: false})
|
|
||||||
policy?: PasswordPolicy;
|
|
||||||
|
|
||||||
getSuccessMessage(): string {
|
getSuccessMessage(): string {
|
||||||
if (this.policy) {
|
if (this.instance) {
|
||||||
return t`Successfully updated policy.`;
|
return t`Successfully updated policy.`;
|
||||||
} else {
|
} else {
|
||||||
return t`Successfully created policy.`;
|
return t`Successfully created policy.`;
|
||||||
|
@ -32,9 +27,9 @@ export class PasswordPolicyForm extends Form<PasswordPolicy> {
|
||||||
}
|
}
|
||||||
|
|
||||||
send = (data: PasswordPolicy): Promise<PasswordPolicy> => {
|
send = (data: PasswordPolicy): Promise<PasswordPolicy> => {
|
||||||
if (this.policy) {
|
if (this.instance) {
|
||||||
return new PoliciesApi(DEFAULT_CONFIG).policiesPasswordUpdate({
|
return new PoliciesApi(DEFAULT_CONFIG).policiesPasswordUpdate({
|
||||||
policyUuid: this.policy.pk || "",
|
policyUuid: this.instance.pk || "",
|
||||||
data: data
|
data: data
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -53,11 +48,11 @@ export class PasswordPolicyForm extends Form<PasswordPolicy> {
|
||||||
label=${t`Name`}
|
label=${t`Name`}
|
||||||
?required=${true}
|
?required=${true}
|
||||||
name="name">
|
name="name">
|
||||||
<input type="text" value="${ifDefined(this.policy?.name || "")}" class="pf-c-form-control" required>
|
<input type="text" value="${ifDefined(this.instance?.name || "")}" class="pf-c-form-control" required>
|
||||||
</ak-form-element-horizontal>
|
</ak-form-element-horizontal>
|
||||||
<ak-form-element-horizontal name="executionLogging">
|
<ak-form-element-horizontal name="executionLogging">
|
||||||
<div class="pf-c-check">
|
<div class="pf-c-check">
|
||||||
<input type="checkbox" class="pf-c-check__input" ?checked=${first(this.policy?.executionLogging, false)}>
|
<input type="checkbox" class="pf-c-check__input" ?checked=${first(this.instance?.executionLogging, false)}>
|
||||||
<label class="pf-c-check__label">
|
<label class="pf-c-check__label">
|
||||||
${t`Execution logging`}
|
${t`Execution logging`}
|
||||||
</label>
|
</label>
|
||||||
|
@ -75,7 +70,7 @@ export class PasswordPolicyForm extends Form<PasswordPolicy> {
|
||||||
label=${t`Password field`}
|
label=${t`Password field`}
|
||||||
?required=${true}
|
?required=${true}
|
||||||
name="passwordField">
|
name="passwordField">
|
||||||
<input type="text" value="${ifDefined(this.policy?.passwordField || "password")}" class="pf-c-form-control" required>
|
<input type="text" value="${ifDefined(this.instance?.passwordField || "password")}" class="pf-c-form-control" required>
|
||||||
<p class="pf-c-form__helper-text">${t`Field key to check, field keys defined in Prompt stages are available.`}</p>
|
<p class="pf-c-form__helper-text">${t`Field key to check, field keys defined in Prompt stages are available.`}</p>
|
||||||
</ak-form-element-horizontal>
|
</ak-form-element-horizontal>
|
||||||
|
|
||||||
|
@ -83,31 +78,31 @@ export class PasswordPolicyForm extends Form<PasswordPolicy> {
|
||||||
label=${t`Minimum length`}
|
label=${t`Minimum length`}
|
||||||
?required=${true}
|
?required=${true}
|
||||||
name="lengthMin">
|
name="lengthMin">
|
||||||
<input type="number" value="${first(this.policy?.lengthMin, 10)}" class="pf-c-form-control" required>
|
<input type="number" value="${first(this.instance?.lengthMin, 10)}" class="pf-c-form-control" required>
|
||||||
</ak-form-element-horizontal>
|
</ak-form-element-horizontal>
|
||||||
<ak-form-element-horizontal
|
<ak-form-element-horizontal
|
||||||
label=${t`Minimum amount of Uppercase Characters`}
|
label=${t`Minimum amount of Uppercase Characters`}
|
||||||
?required=${true}
|
?required=${true}
|
||||||
name="amountUppercase">
|
name="amountUppercase">
|
||||||
<input type="number" value="${first(this.policy?.amountUppercase, 2)}" class="pf-c-form-control" required>
|
<input type="number" value="${first(this.instance?.amountUppercase, 2)}" class="pf-c-form-control" required>
|
||||||
</ak-form-element-horizontal>
|
</ak-form-element-horizontal>
|
||||||
<ak-form-element-horizontal
|
<ak-form-element-horizontal
|
||||||
label=${t`Minimum amount of Lowercase Characters`}
|
label=${t`Minimum amount of Lowercase Characters`}
|
||||||
?required=${true}
|
?required=${true}
|
||||||
name="amountLowercase">
|
name="amountLowercase">
|
||||||
<input type="number" value="${first(this.policy?.amountLowercase, 2)}" class="pf-c-form-control" required>
|
<input type="number" value="${first(this.instance?.amountLowercase, 2)}" class="pf-c-form-control" required>
|
||||||
</ak-form-element-horizontal>
|
</ak-form-element-horizontal>
|
||||||
<ak-form-element-horizontal
|
<ak-form-element-horizontal
|
||||||
label=${t`Minimum amount of Symbols Characters`}
|
label=${t`Minimum amount of Symbols Characters`}
|
||||||
?required=${true}
|
?required=${true}
|
||||||
name="amountSymbols">
|
name="amountSymbols">
|
||||||
<input type="number" value="${first(this.policy?.amountSymbols, 2)}" class="pf-c-form-control" required>
|
<input type="number" value="${first(this.instance?.amountSymbols, 2)}" class="pf-c-form-control" required>
|
||||||
</ak-form-element-horizontal>
|
</ak-form-element-horizontal>
|
||||||
<ak-form-element-horizontal
|
<ak-form-element-horizontal
|
||||||
label=${t`Error message`}
|
label=${t`Error message`}
|
||||||
?required=${true}
|
?required=${true}
|
||||||
name="errorMessage">
|
name="errorMessage">
|
||||||
<input type="text" value="${ifDefined(this.policy?.errorMessage)}" class="pf-c-form-control" required>
|
<input type="text" value="${ifDefined(this.instance?.errorMessage)}" class="pf-c-form-control" required>
|
||||||
</ak-form-element-horizontal>
|
</ak-form-element-horizontal>
|
||||||
</div>
|
</div>
|
||||||
</ak-form-group>
|
</ak-form-group>
|
||||||
|
@ -120,7 +115,7 @@ export class PasswordPolicyForm extends Form<PasswordPolicy> {
|
||||||
label=${t`Symbol charset`}
|
label=${t`Symbol charset`}
|
||||||
?required=${true}
|
?required=${true}
|
||||||
name="symbolCharset">
|
name="symbolCharset">
|
||||||
<input type="text" value="${ifDefined(this.policy?.symbolCharset || "!\\\"#$%&'()*+,-./:;<=>?@[]^_`{|}~ ")}" class="pf-c-form-control" required>
|
<input type="text" value="${ifDefined(this.instance?.symbolCharset || "!\\\"#$%&'()*+,-./:;<=>?@[]^_`{|}~ ")}" class="pf-c-form-control" required>
|
||||||
<p class="pf-c-form__helper-text">${t`Characters which are considered as symbols.`}</p>
|
<p class="pf-c-form__helper-text">${t`Characters which are considered as symbols.`}</p>
|
||||||
</ak-form-element-horizontal>
|
</ak-form-element-horizontal>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,30 +1,25 @@
|
||||||
import { ReputationPolicy, PoliciesApi } from "authentik-api";
|
import { ReputationPolicy, PoliciesApi } from "authentik-api";
|
||||||
import { t } from "@lingui/macro";
|
import { t } from "@lingui/macro";
|
||||||
import { customElement, property } from "lit-element";
|
import { customElement } from "lit-element";
|
||||||
import { html, TemplateResult } from "lit-html";
|
import { html, TemplateResult } from "lit-html";
|
||||||
import { DEFAULT_CONFIG } from "../../../api/Config";
|
import { DEFAULT_CONFIG } from "../../../api/Config";
|
||||||
import { Form } from "../../../elements/forms/Form";
|
|
||||||
import { ifDefined } from "lit-html/directives/if-defined";
|
import { ifDefined } from "lit-html/directives/if-defined";
|
||||||
import "../../../elements/forms/HorizontalFormElement";
|
import "../../../elements/forms/HorizontalFormElement";
|
||||||
import "../../../elements/forms/FormGroup";
|
import "../../../elements/forms/FormGroup";
|
||||||
import { first } from "../../../utils";
|
import { first } from "../../../utils";
|
||||||
|
import { ModelForm } from "../../../elements/forms/ModelForm";
|
||||||
|
|
||||||
@customElement("ak-policy-reputation-form")
|
@customElement("ak-policy-reputation-form")
|
||||||
export class ReputationPolicyForm extends Form<ReputationPolicy> {
|
export class ReputationPolicyForm extends ModelForm<ReputationPolicy, string> {
|
||||||
|
|
||||||
set policyUUID(value: string) {
|
loadInstance(pk: string): Promise<ReputationPolicy> {
|
||||||
new PoliciesApi(DEFAULT_CONFIG).policiesReputationRead({
|
return new PoliciesApi(DEFAULT_CONFIG).policiesReputationRead({
|
||||||
policyUuid: value,
|
policyUuid: pk,
|
||||||
}).then(policy => {
|
|
||||||
this.policy = policy;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@property({attribute: false})
|
|
||||||
policy?: ReputationPolicy;
|
|
||||||
|
|
||||||
getSuccessMessage(): string {
|
getSuccessMessage(): string {
|
||||||
if (this.policy) {
|
if (this.instance) {
|
||||||
return t`Successfully updated policy.`;
|
return t`Successfully updated policy.`;
|
||||||
} else {
|
} else {
|
||||||
return t`Successfully created policy.`;
|
return t`Successfully created policy.`;
|
||||||
|
@ -32,9 +27,9 @@ export class ReputationPolicyForm extends Form<ReputationPolicy> {
|
||||||
}
|
}
|
||||||
|
|
||||||
send = (data: ReputationPolicy): Promise<ReputationPolicy> => {
|
send = (data: ReputationPolicy): Promise<ReputationPolicy> => {
|
||||||
if (this.policy) {
|
if (this.instance) {
|
||||||
return new PoliciesApi(DEFAULT_CONFIG).policiesReputationUpdate({
|
return new PoliciesApi(DEFAULT_CONFIG).policiesReputationUpdate({
|
||||||
policyUuid: this.policy.pk || "",
|
policyUuid: this.instance.pk || "",
|
||||||
data: data
|
data: data
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -53,11 +48,11 @@ export class ReputationPolicyForm extends Form<ReputationPolicy> {
|
||||||
label=${t`Name`}
|
label=${t`Name`}
|
||||||
?required=${true}
|
?required=${true}
|
||||||
name="name">
|
name="name">
|
||||||
<input type="text" value="${ifDefined(this.policy?.name || "")}" class="pf-c-form-control" required>
|
<input type="text" value="${ifDefined(this.instance?.name || "")}" class="pf-c-form-control" required>
|
||||||
</ak-form-element-horizontal>
|
</ak-form-element-horizontal>
|
||||||
<ak-form-element-horizontal name="executionLogging">
|
<ak-form-element-horizontal name="executionLogging">
|
||||||
<div class="pf-c-check">
|
<div class="pf-c-check">
|
||||||
<input type="checkbox" class="pf-c-check__input" ?checked=${first(this.policy?.executionLogging, false)}>
|
<input type="checkbox" class="pf-c-check__input" ?checked=${first(this.instance?.executionLogging, false)}>
|
||||||
<label class="pf-c-check__label">
|
<label class="pf-c-check__label">
|
||||||
${t`Execution logging`}
|
${t`Execution logging`}
|
||||||
</label>
|
</label>
|
||||||
|
@ -73,7 +68,7 @@ export class ReputationPolicyForm extends Form<ReputationPolicy> {
|
||||||
<div slot="body" class="pf-c-form">
|
<div slot="body" class="pf-c-form">
|
||||||
<ak-form-element-horizontal name="checkIp">
|
<ak-form-element-horizontal name="checkIp">
|
||||||
<div class="pf-c-check">
|
<div class="pf-c-check">
|
||||||
<input type="checkbox" class="pf-c-check__input" ?checked=${first(this.policy?.checkIp, false)}>
|
<input type="checkbox" class="pf-c-check__input" ?checked=${first(this.instance?.checkIp, false)}>
|
||||||
<label class="pf-c-check__label">
|
<label class="pf-c-check__label">
|
||||||
${t`Check IP`}
|
${t`Check IP`}
|
||||||
</label>
|
</label>
|
||||||
|
@ -81,7 +76,7 @@ export class ReputationPolicyForm extends Form<ReputationPolicy> {
|
||||||
</ak-form-element-horizontal>
|
</ak-form-element-horizontal>
|
||||||
<ak-form-element-horizontal name="checkUsername">
|
<ak-form-element-horizontal name="checkUsername">
|
||||||
<div class="pf-c-check">
|
<div class="pf-c-check">
|
||||||
<input type="checkbox" class="pf-c-check__input" ?checked=${first(this.policy?.checkUsername, false)}>
|
<input type="checkbox" class="pf-c-check__input" ?checked=${first(this.instance?.checkUsername, false)}>
|
||||||
<label class="pf-c-check__label">
|
<label class="pf-c-check__label">
|
||||||
${t`Check Username`}
|
${t`Check Username`}
|
||||||
</label>
|
</label>
|
||||||
|
@ -91,7 +86,7 @@ export class ReputationPolicyForm extends Form<ReputationPolicy> {
|
||||||
label=${t`Threshold`}
|
label=${t`Threshold`}
|
||||||
?required=${true}
|
?required=${true}
|
||||||
name="threshold">
|
name="threshold">
|
||||||
<input type="number" value="${ifDefined(this.policy?.threshold || -5)}" class="pf-c-form-control" required>
|
<input type="number" value="${ifDefined(this.instance?.threshold || -5)}" class="pf-c-form-control" required>
|
||||||
</ak-form-element-horizontal>
|
</ak-form-element-horizontal>
|
||||||
</div>
|
</div>
|
||||||
</ak-form-group>
|
</ak-form-group>
|
||||||
|
|
Reference in New Issue