core: add API endpoint to directly set user's password

closes #2040

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer
2022-01-03 13:30:39 +01:00
parent d18a691f63
commit 3e22740eac
11 changed files with 234 additions and 35 deletions

View File

@ -3441,6 +3441,7 @@ msgstr "Passing"
#: src/flows/stages/identification/IdentificationStage.ts
#: src/flows/stages/password/PasswordStage.ts
#: src/pages/users/ServiceAccountForm.ts
#: src/pages/users/UserPasswordForm.ts
msgid "Password"
msgstr "Password"
@ -4259,6 +4260,10 @@ msgstr "Set a custom HTTP-Basic Authentication header based on values from authe
msgid "Set custom attributes using YAML or JSON."
msgstr "Set custom attributes using YAML or JSON."
#: src/pages/users/UserListPage.ts
msgid "Set password"
msgstr "Set password"
#: src/pages/providers/proxy/ProxyProviderForm.ts
msgid "Set this to the domain you wish the authentication to be valid for. Must be a parent domain of the URL above. If you're running applications as app1.domain.tld, app2.domain.tld, set this to 'domain.tld'."
msgstr "Set this to the domain you wish the authentication to be valid for. Must be a parent domain of the URL above. If you're running applications as app1.domain.tld, app2.domain.tld, set this to 'domain.tld'."
@ -4765,6 +4770,10 @@ msgstr "Successfully updated mapping."
msgid "Successfully updated outpost."
msgstr "Successfully updated outpost."
#: src/pages/users/UserPasswordForm.ts
msgid "Successfully updated password."
msgstr "Successfully updated password."
#: src/pages/policies/dummy/DummyPolicyForm.ts
#: src/pages/policies/event_matcher/EventMatcherPolicyForm.ts
#: src/pages/policies/expiry/ExpiryPolicyForm.ts
@ -5155,8 +5164,12 @@ msgid "To create a recovery link, the current tenant needs to have a recovery fl
msgstr "To create a recovery link, the current tenant needs to have a recovery flow configured."
#: src/pages/users/UserListPage.ts
msgid "To directly reset a user's password, configure a recovery flow on the currently active tenant."
msgstr "To directly reset a user's password, configure a recovery flow on the currently active tenant."
#~ msgid "To directly reset a user's password, configure a recovery flow on the currently active tenant."
#~ msgstr "To directly reset a user's password, configure a recovery flow on the currently active tenant."
#: src/pages/users/UserListPage.ts
msgid "To let a user directly reset a their password, configure a recovery flow on the currently active tenant."
msgstr "To let a user directly reset a their password, configure a recovery flow on the currently active tenant."
#: src/pages/sources/ldap/LDAPSourceForm.ts
msgid "To use SSL instead, use 'ldaps://' and disable this option."
@ -5520,6 +5533,11 @@ msgstr "Update available"
msgid "Update details"
msgstr "Update details"
#: src/pages/users/UserListPage.ts
#: src/pages/users/UserListPage.ts
msgid "Update password"
msgstr "Update password"
#: src/pages/flows/BoundStagesList.ts
#: src/pages/outposts/ServiceConnectionListPage.ts
#: src/pages/policies/BoundPoliciesList.ts

View File

@ -3414,6 +3414,7 @@ msgstr "Réussite"
#: src/flows/stages/identification/IdentificationStage.ts
#: src/flows/stages/password/PasswordStage.ts
#: src/pages/users/ServiceAccountForm.ts
#: src/pages/users/UserPasswordForm.ts
msgid "Password"
msgstr "Mot de passe"
@ -4223,6 +4224,10 @@ msgstr "Définir un en-tête d'authentification HTTP-Basic personnalisé basé s
msgid "Set custom attributes using YAML or JSON."
msgstr "Définissez des attributs personnalisés via YAML ou JSON."
#: src/pages/users/UserListPage.ts
msgid "Set password"
msgstr ""
#: src/pages/providers/proxy/ProxyProviderForm.ts
msgid "Set this to the domain you wish the authentication to be valid for. Must be a parent domain of the URL above. If you're running applications as app1.domain.tld, app2.domain.tld, set this to 'domain.tld'."
msgstr ""
@ -4724,6 +4729,10 @@ msgstr "Mapping mis à jour avec succès"
msgid "Successfully updated outpost."
msgstr "Avant-poste mis à jour avec succès"
#: src/pages/users/UserPasswordForm.ts
msgid "Successfully updated password."
msgstr ""
#: src/pages/policies/dummy/DummyPolicyForm.ts
#: src/pages/policies/event_matcher/EventMatcherPolicyForm.ts
#: src/pages/policies/expiry/ExpiryPolicyForm.ts
@ -5099,8 +5108,12 @@ msgid "To create a recovery link, the current tenant needs to have a recovery fl
msgstr "Pour créer un lien de récupération, le locataire actuel doit avoir un flux de récupération configuré."
#: src/pages/users/UserListPage.ts
msgid "To directly reset a user's password, configure a recovery flow on the currently active tenant."
msgstr "Pour réinitialiser directement le mot de passe d'un utilisateur, configurez un flux de récupération sur le locataire actuel."
#~ msgid "To directly reset a user's password, configure a recovery flow on the currently active tenant."
#~ msgstr "Pour réinitialiser directement le mot de passe d'un utilisateur, configurez un flux de récupération sur le locataire actuel."
#: src/pages/users/UserListPage.ts
msgid "To let a user directly reset a their password, configure a recovery flow on the currently active tenant."
msgstr ""
#: src/pages/sources/ldap/LDAPSourceForm.ts
msgid "To use SSL instead, use 'ldaps://' and disable this option."
@ -5461,6 +5474,11 @@ msgstr "Mise à jour disponibl"
msgid "Update details"
msgstr "Détails de la mise à jour"
#: src/pages/users/UserListPage.ts
#: src/pages/users/UserListPage.ts
msgid "Update password"
msgstr ""
#: src/pages/flows/BoundStagesList.ts
#: src/pages/outposts/ServiceConnectionListPage.ts
#: src/pages/policies/BoundPoliciesList.ts

View File

@ -3431,6 +3431,7 @@ msgstr ""
#: src/flows/stages/identification/IdentificationStage.ts
#: src/flows/stages/password/PasswordStage.ts
#: src/pages/users/ServiceAccountForm.ts
#: src/pages/users/UserPasswordForm.ts
msgid "Password"
msgstr ""
@ -4249,6 +4250,10 @@ msgstr ""
msgid "Set custom attributes using YAML or JSON."
msgstr ""
#: src/pages/users/UserListPage.ts
msgid "Set password"
msgstr ""
#: src/pages/providers/proxy/ProxyProviderForm.ts
msgid "Set this to the domain you wish the authentication to be valid for. Must be a parent domain of the URL above. If you're running applications as app1.domain.tld, app2.domain.tld, set this to 'domain.tld'."
msgstr ""
@ -4755,6 +4760,10 @@ msgstr ""
msgid "Successfully updated outpost."
msgstr ""
#: src/pages/users/UserPasswordForm.ts
msgid "Successfully updated password."
msgstr ""
#: src/pages/policies/dummy/DummyPolicyForm.ts
#: src/pages/policies/event_matcher/EventMatcherPolicyForm.ts
#: src/pages/policies/expiry/ExpiryPolicyForm.ts
@ -5135,7 +5144,11 @@ msgid "To create a recovery link, the current tenant needs to have a recovery fl
msgstr ""
#: src/pages/users/UserListPage.ts
msgid "To directly reset a user's password, configure a recovery flow on the currently active tenant."
#~ msgid "To directly reset a user's password, configure a recovery flow on the currently active tenant."
#~ msgstr ""
#: src/pages/users/UserListPage.ts
msgid "To let a user directly reset a their password, configure a recovery flow on the currently active tenant."
msgstr ""
#: src/pages/sources/ldap/LDAPSourceForm.ts
@ -5500,6 +5513,11 @@ msgstr ""
msgid "Update details"
msgstr ""
#: src/pages/users/UserListPage.ts
#: src/pages/users/UserListPage.ts
msgid "Update password"
msgstr ""
#: src/pages/flows/BoundStagesList.ts
#: src/pages/outposts/ServiceConnectionListPage.ts
#: src/pages/policies/BoundPoliciesList.ts

View File

@ -3383,6 +3383,7 @@ msgstr "Geçiyor"
#: src/flows/stages/identification/IdentificationStage.ts
#: src/flows/stages/password/PasswordStage.ts
#: src/pages/users/ServiceAccountForm.ts
#: src/pages/users/UserPasswordForm.ts
msgid "Password"
msgstr "Parola"
@ -4182,6 +4183,10 @@ msgstr "authentik değerlerine göre özel bir HTTP-Basic Kimlik Doğrulama baş
msgid "Set custom attributes using YAML or JSON."
msgstr "YAML veya JSON kullanarak özel nitelikleri ayarlayın."
#: src/pages/users/UserListPage.ts
msgid "Set password"
msgstr ""
#: src/pages/providers/proxy/ProxyProviderForm.ts
msgid "Set this to the domain you wish the authentication to be valid for. Must be a parent domain of the URL above. If you're running applications as app1.domain.tld, app2.domain.tld, set this to 'domain.tld'."
msgstr "Bunu kimlik doğrulamasının geçerli olmasını istediğiniz etki alanına ayarlayın. Yukarıdaki URL'nin bir üst etki alanı olmalıdır. Uygulamaları app1.domain.tld, app2.domain.tld olarak çalıştırıyorsanız, bunu 'domain.tld' olarak ayarlayın."
@ -4671,6 +4676,10 @@ msgstr "Eşleme başarıyla güncellendi."
msgid "Successfully updated outpost."
msgstr "İleri üssü başarıyla güncelledi."
#: src/pages/users/UserPasswordForm.ts
msgid "Successfully updated password."
msgstr ""
#: src/pages/policies/dummy/DummyPolicyForm.ts
#: src/pages/policies/event_matcher/EventMatcherPolicyForm.ts
#: src/pages/policies/expiry/ExpiryPolicyForm.ts
@ -5050,8 +5059,12 @@ msgid "To create a recovery link, the current tenant needs to have a recovery fl
msgstr "Kurtarma bağlantısı oluşturmak için geçerli sakinin yapılandırılmış bir kurtarma akışı olması gerekir."
#: src/pages/users/UserListPage.ts
msgid "To directly reset a user's password, configure a recovery flow on the currently active tenant."
msgstr "Bir kullanıcının parolasını doğrudan sıfırlamak için, etkin olan sakin üzerinde bir kurtarma akışı yapılandırın."
#~ msgid "To directly reset a user's password, configure a recovery flow on the currently active tenant."
#~ msgstr "Bir kullanıcının parolasını doğrudan sıfırlamak için, etkin olan sakin üzerinde bir kurtarma akışı yapılandırın."
#: src/pages/users/UserListPage.ts
msgid "To let a user directly reset a their password, configure a recovery flow on the currently active tenant."
msgstr ""
#: src/pages/sources/ldap/LDAPSourceForm.ts
msgid "To use SSL instead, use 'ldaps://' and disable this option."
@ -5412,6 +5425,11 @@ msgstr "Güncelleme mevcut"
msgid "Update details"
msgstr "Ayrıntıları güncelle"
#: src/pages/users/UserListPage.ts
#: src/pages/users/UserListPage.ts
msgid "Update password"
msgstr ""
#: src/pages/flows/BoundStagesList.ts
#: src/pages/outposts/ServiceConnectionListPage.ts
#: src/pages/policies/BoundPoliciesList.ts

View File

@ -404,7 +404,7 @@ export class ProxyProviderFormPage extends ModelForm<ProxyProvider, number> {
<ak-form-element-horizontal
label="${this.mode === ProxyMode.ForwardDomain
? t`Unauthenticated URLs`
: t`Unauthenticated Paths`}${t``}"
: t`Unauthenticated Paths`}"
name="skipPathRegex"
>
<textarea class="pf-c-form-control">

View File

@ -26,6 +26,7 @@ import { first } from "../../utils";
import "./ServiceAccountForm";
import "./UserActiveForm";
import "./UserForm";
import "./UserPasswordForm";
import "./UserResetEmailForm";
@customElement("ak-user-list")
@ -136,11 +137,11 @@ export class UserListPage extends TablePage<User> {
<div>${item.username}</div>
<small>${item.name}</small>
</a>`,
html` <ak-label color=${item.isActive ? PFColor.Green : PFColor.Red}>
html`<ak-label color=${item.isActive ? PFColor.Green : PFColor.Red}>
${item.isActive ? t`Yes` : t`No`}
</ak-label>`,
html`${first(item.lastLogin?.toLocaleString(), t`-`)}`,
html` <ak-forms-modal>
html`<ak-forms-modal>
<span slot="submit"> ${t`Update`} </span>
<span slot="header"> ${t`Update User`} </span>
<ak-user-form slot="form" .instancePk=${item.pk}> </ak-user-form>
@ -204,12 +205,23 @@ export class UserListPage extends TablePage<User> {
</dt>
<dd class="pf-c-description-list__description">
<div class="pf-c-description-list__text">
<ak-forms-modal>
<span slot="submit">${t`Update password`}</span>
<span slot="header">${t`Update password`}</span>
<ak-user-password-form
slot="form"
.instancePk=${item.pk}
></ak-user-password-form>
<button slot="trigger" class="pf-c-button pf-m-secondary">
${t`Set password`}
</button>
</ak-forms-modal>
${until(
tenant().then((tenant) => {
if (!tenant.flowRecovery) {
return html`
<p>
${t`To directly reset a user's password, configure a recovery flow on the currently active tenant.`}
${t`To let a user directly reset a their password, configure a recovery flow on the currently active tenant.`}
</p>
`;
}

View File

@ -0,0 +1,36 @@
import { t } from "@lingui/macro";
import { TemplateResult, html } from "lit";
import { customElement, property } from "lit/decorators.js";
import { CoreApi, UserPasswordSetRequest } from "@goauthentik/api";
import { DEFAULT_CONFIG } from "../../api/Config";
import "../../elements/buttons/SpinnerButton";
import { Form } from "../../elements/forms/Form";
import "../../elements/forms/HorizontalFormElement";
@customElement("ak-user-password-form")
export class UserPasswordForm extends Form<UserPasswordSetRequest> {
@property({ type: Number })
instancePk?: number;
getSuccessMessage(): string {
return t`Successfully updated password.`;
}
send = (data: UserPasswordSetRequest): Promise<void> => {
return new CoreApi(DEFAULT_CONFIG).coreUsersSetPasswordCreate({
id: this.instancePk || 0,
userPasswordSetRequest: data,
});
};
renderForm(): TemplateResult {
return html`<form class="pf-c-form pf-m-horizontal">
<ak-form-element-horizontal label=${t`Password`} ?required=${true} name="password">
<input type="password" value="" class="pf-c-form-control" required />
</ak-form-element-horizontal>
</form>`;
}
}