-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
core: add ability to provide reason for impersonation #11951
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
e152a6f
f2de64a
9f27754
bc77e95
a19d2b0
8b5f0df
f500069
88a2082
3b31892
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # Generated by Django 5.0.9 on 2024-11-07 15:08 | ||
|
|
||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ("authentik_tenants", "0003_alter_tenant_default_token_duration"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AddField( | ||
| model_name="tenant", | ||
| name="impersonation_require_reason", | ||
| field=models.BooleanField( | ||
| default=True, | ||
| help_text="Require administrators to provide a reason for impersonating a user.", | ||
| ), | ||
| ), | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; | ||
| import "@goauthentik/components/ak-text-input"; | ||
| import { Form } from "@goauthentik/elements/forms/Form"; | ||
|
|
||
| import { msg } from "@lit/localize"; | ||
| import { TemplateResult, html } from "lit"; | ||
| import { customElement, property } from "lit/decorators.js"; | ||
|
|
||
| import { CoreApi, ImpersonationRequest } from "@goauthentik/api"; | ||
|
|
||
| @customElement("ak-user-impersonate-form") | ||
| export class UserImpersonateForm extends Form<ImpersonationRequest> { | ||
| @property({ type: Number }) | ||
| instancePk?: number; | ||
|
|
||
| async send(data: ImpersonationRequest): Promise<void> { | ||
| return new CoreApi(DEFAULT_CONFIG).coreUsersImpersonateCreate({ | ||
| id: this.instancePk || 0, | ||
| impersonationRequest: data, | ||
| }); | ||
| // .then(() => { | ||
| // window.location.href = "/"; | ||
| // }); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Assuming this is commented out for testing?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, this shouldn't be commented out
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let me just try out again if that works
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep, all good |
||
| } | ||
|
|
||
| renderForm(): TemplateResult { | ||
| return html`<ak-text-input | ||
| name="reason" | ||
| label=${msg("Reason")} | ||
| help=${msg("Reason for impersonating the user")} | ||
| ></ak-text-input>`; | ||
| } | ||
| } | ||
|
|
||
| declare global { | ||
| interface HTMLElementTagNameMap { | ||
| "ak-user-impersonate-form": UserImpersonateForm; | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.