
* events: migrate system tasks to save in DB Signed-off-by: Jens Langhammer <jens@goauthentik.io> * prefill in app startup Signed-off-by: Jens Langhammer <jens@goauthentik.io> * cleanup api Signed-off-by: Jens Langhammer <jens@goauthentik.io> * update web Signed-off-by: Jens Langhammer <jens@goauthentik.io> * use string for status Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix enum Signed-off-by: Jens Langhammer <jens@goauthentik.io> * save start and end directly in timestamp from default_timer() Signed-off-by: Jens Langhammer <jens@goauthentik.io> * improve metrics Signed-off-by: Jens Langhammer <jens@goauthentik.io> * lint Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix tests Signed-off-by: Jens Langhammer <jens@goauthentik.io> * rename globally to system task Signed-off-by: Jens Langhammer <jens@goauthentik.io> * recreate migrations, better denote anonymous user Signed-off-by: Jens Langhammer <jens@goauthentik.io> * events: lookup actual django app instead of using module path, fallback to module path Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix logger call Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: Jens Langhammer <jens@goauthentik.io>
105 lines
3.6 KiB
TypeScript
105 lines
3.6 KiB
TypeScript
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
|
import { uiConfig } from "@goauthentik/common/ui/config";
|
|
import "@goauthentik/elements/buttons/ModalButton";
|
|
import "@goauthentik/elements/buttons/SpinnerButton";
|
|
import "@goauthentik/elements/forms/DeleteBulkForm";
|
|
import "@goauthentik/elements/forms/ModalForm";
|
|
import "@goauthentik/elements/rbac/ObjectPermissionModal";
|
|
import { PaginatedResponse } from "@goauthentik/elements/table/Table";
|
|
import { TableColumn } from "@goauthentik/elements/table/Table";
|
|
import { TablePage } from "@goauthentik/elements/table/TablePage";
|
|
import getUnicodeFlagIcon from "country-flag-icons/unicode";
|
|
|
|
import { msg } from "@lit/localize";
|
|
import { TemplateResult, html } from "lit";
|
|
import { customElement, property } from "lit/decorators.js";
|
|
|
|
import {
|
|
PoliciesApi,
|
|
RbacPermissionsAssignedByUsersListModelEnum,
|
|
Reputation,
|
|
} from "@goauthentik/api";
|
|
|
|
@customElement("ak-policy-reputation-list")
|
|
export class ReputationListPage extends TablePage<Reputation> {
|
|
searchEnabled(): boolean {
|
|
return true;
|
|
}
|
|
pageTitle(): string {
|
|
return msg("Reputation scores");
|
|
}
|
|
pageDescription(): string {
|
|
return msg(
|
|
"Reputation for IP and user identifiers. Scores are decreased for each failed login and increased for each successful login.",
|
|
);
|
|
}
|
|
pageIcon(): string {
|
|
return "fa fa-ban";
|
|
}
|
|
|
|
@property()
|
|
order = "identifier";
|
|
|
|
checkbox = true;
|
|
|
|
async apiEndpoint(page: number): Promise<PaginatedResponse<Reputation>> {
|
|
return new PoliciesApi(DEFAULT_CONFIG).policiesReputationScoresList({
|
|
ordering: this.order,
|
|
page: page,
|
|
pageSize: (await uiConfig()).pagination.perPage,
|
|
search: this.search || "",
|
|
});
|
|
}
|
|
|
|
columns(): TableColumn[] {
|
|
return [
|
|
new TableColumn(msg("Identifier"), "identifier"),
|
|
new TableColumn(msg("IP"), "ip"),
|
|
new TableColumn(msg("Score"), "score"),
|
|
new TableColumn(msg("Updated"), "updated"),
|
|
new TableColumn(msg("Actions")),
|
|
];
|
|
}
|
|
|
|
renderToolbarSelected(): TemplateResult {
|
|
const disabled = this.selectedElements.length < 1;
|
|
return html`<ak-forms-delete-bulk
|
|
objectLabel=${msg("Reputation")}
|
|
.objects=${this.selectedElements}
|
|
.usedBy=${(item: Reputation) => {
|
|
return new PoliciesApi(DEFAULT_CONFIG).policiesReputationScoresUsedByList({
|
|
reputationUuid: item.pk || "",
|
|
});
|
|
}}
|
|
.delete=${(item: Reputation) => {
|
|
return new PoliciesApi(DEFAULT_CONFIG).policiesReputationScoresDestroy({
|
|
reputationUuid: item.pk || "",
|
|
});
|
|
}}
|
|
>
|
|
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
|
|
${msg("Delete")}
|
|
</button>
|
|
</ak-forms-delete-bulk>`;
|
|
}
|
|
|
|
row(item: Reputation): TemplateResult[] {
|
|
return [
|
|
html`${item.identifier}`,
|
|
html`${item.ipGeoData?.country
|
|
? html` ${getUnicodeFlagIcon(item.ipGeoData.country)} `
|
|
: html``}
|
|
${item.ip}`,
|
|
html`${item.score}`,
|
|
html`${item.updated.toLocaleString()}`,
|
|
html`
|
|
<ak-rbac-object-permission-modal
|
|
model=${RbacPermissionsAssignedByUsersListModelEnum.PoliciesReputationReputationpolicy}
|
|
objectPk=${item.pk || ""}
|
|
>
|
|
</ak-rbac-object-permission-modal>
|
|
`,
|
|
];
|
|
}
|
|
}
|