Skip to content
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

web: provide 'show password' button #10337

Merged
merged 74 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
3146e5a
web: fix esbuild issue with style sheets
kensternberg-authentik Mar 8, 2024
fe52f44
Merge branch 'main' into dev
kensternberg-authentik Mar 11, 2024
e505f27
Merge branch 'main' into dev
kensternberg-authentik Mar 11, 2024
5090621
Merge branch 'main' into dev
kensternberg-authentik Mar 11, 2024
035bda4
Merge branch 'main' into dev
kensternberg-authentik Mar 12, 2024
2d0117d
Merge branch 'main' into dev
kensternberg-authentik Mar 13, 2024
22cb5b7
Merge branch 'main' into dev
kensternberg-authentik Mar 14, 2024
8b4e036
Merge branch 'main' into dev
kensternberg-authentik Mar 14, 2024
db96e1a
Merge branch 'main' into dev
kensternberg-authentik Mar 18, 2024
8946b81
Merge branch 'main' into dev
kensternberg-authentik Mar 19, 2024
30beca9
Merge branch 'main' into dev
kensternberg-authentik Mar 19, 2024
5d84082
Merge branch 'main' into dev
kensternberg-authentik Mar 20, 2024
a7e3dca
Merge branch 'main' into dev
kensternberg-authentik Mar 21, 2024
2d254d6
Merge branch 'main' into dev
kensternberg-authentik Mar 25, 2024
3f95020
Merge branch 'main' into dev
kensternberg-authentik Mar 26, 2024
a056703
Merge branch 'main' into dev
kensternberg-authentik Mar 27, 2024
fc00bde
Merge branch 'main' into dev
kensternberg-authentik Mar 29, 2024
7123b2c
Merge branch 'main' into dev
kensternberg-authentik Mar 29, 2024
5d4c380
Merge branch 'main' into dev
kensternberg-authentik Apr 1, 2024
66cefcc
Merge branch 'main' into dev
kensternberg-authentik Apr 2, 2024
875fc5c
Merge branch 'main' into dev
kensternberg-authentik Apr 4, 2024
c84be1d
Merge branch 'main' into dev
kensternberg-authentik Apr 8, 2024
b08dcc2
Merge branch 'main' into dev
kensternberg-authentik Apr 9, 2024
272fdc5
Merge branch 'main' into dev
kensternberg-authentik Apr 10, 2024
23665d1
Merge branch 'main' into dev
kensternberg-authentik Apr 10, 2024
cacdf64
Merge branch 'main' into dev
kensternberg-authentik Apr 11, 2024
085debf
Merge branch 'main' into dev
kensternberg-authentik Apr 12, 2024
f19ed14
Merge branch 'main' into dev
kensternberg-authentik Apr 16, 2024
ac4ba5d
Merge branch 'main' into dev
kensternberg-authentik Apr 17, 2024
98503f6
Merge branch 'main' into dev
kensternberg-authentik Apr 18, 2024
2d94b16
Merge branch 'main' into dev
kensternberg-authentik Apr 22, 2024
34de6bf
Merge branch 'main' into dev
kensternberg-authentik Apr 24, 2024
ca42506
Merge branch 'main' into dev
kensternberg-authentik Apr 25, 2024
2a96900
Merge branch 'main' into dev
kensternberg-authentik May 2, 2024
9acebec
Merge branch 'main' into dev
kensternberg-authentik May 3, 2024
8248163
Merge branch 'main' into dev
kensternberg-authentik May 3, 2024
ee37e92
Merge branch 'main' into dev
kensternberg-authentik May 7, 2024
e1d565d
Merge branch 'main' into dev
kensternberg-authentik May 8, 2024
3d532d4
Merge branch 'main' into dev
kensternberg-authentik May 9, 2024
fffc8c7
Merge branch 'main' into dev
kensternberg-authentik May 10, 2024
3fae9e5
Merge branch 'main' into dev
kensternberg-authentik May 13, 2024
09803fe
Merge branch 'main' into dev
kensternberg-authentik May 14, 2024
5752497
Merge branch 'main' into dev
kensternberg-authentik May 17, 2024
61eb9fa
Merge branch 'main' into dev
kensternberg-authentik May 22, 2024
3ff20ca
Merge branch 'main' into dev
kensternberg-authentik May 24, 2024
5b132c8
Merge branch 'main' into dev
kensternberg-authentik May 28, 2024
2488eb9
Merge branch 'main' into dev
kensternberg-authentik Jun 3, 2024
312f364
Merge branch 'main' into dev
kensternberg-authentik Jun 4, 2024
fcab990
Merge branch 'main' into dev
kensternberg-authentik Jun 11, 2024
10bfc4e
erge branch 'main' into dev
kensternberg-authentik Jun 13, 2024
c49185d
Merge branch 'main' into dev
kensternberg-authentik Jun 14, 2024
7b208d9
Merge branch 'main' into dev
kensternberg-authentik Jun 18, 2024
75b605f
Merge branch 'main' into dev
kensternberg-authentik Jun 19, 2024
186e1bf
Merge branch 'main' into dev
kensternberg-authentik Jun 20, 2024
be9b44a
Merge branch 'main' into dev
kensternberg-authentik Jun 24, 2024
44e4a5a
Merge branch 'main' into dev
kensternberg-authentik Jun 27, 2024
833317c
Merge branch 'main' into dev
kensternberg-authentik Jun 27, 2024
db059d9
Merge branch 'main' into dev
kensternberg-authentik Jun 28, 2024
fec46df
Merge branch 'main' into dev
kensternberg-authentik Jun 29, 2024
720f175
Merge branch 'main' into dev
kensternberg-authentik Jul 1, 2024
e70c5a1
Merge branch 'main' into dev
kensternberg-authentik Jul 2, 2024
7a4fdc8
web: provide `show password` on login page
kensternberg-authentik Jul 2, 2024
5a340a5
web: comment doesn't need to be exposed. It's sufficient where it is .
kensternberg-authentik Jul 2, 2024
492d00d
web: fix button rendering issues
kensternberg-authentik Jul 2, 2024
99fd1a9
web: provide `show password` on login page
kensternberg-authentik Jul 2, 2024
587ec68
ensure the tests pass; quibbling over the wording of the admin field …
kensternberg-authentik Jul 2, 2024
0b05d43
Removed some manually identified fluff.
kensternberg-authentik Jul 2, 2024
067d4e4
web: break out `show password`-enabled input field into its own compo…
kensternberg-authentik Jul 3, 2024
a6eb120
Merge branch 'main' into web/cf/provide-show-password-button
kensternberg-authentik Jul 3, 2024
3bc1a78
Merge branch 'main' into web/cf/provide-show-password-button
kensternberg-authentik Jul 3, 2024
7719cfc
I guess 'challenge type' has been eliminated as a field.
kensternberg-authentik Jul 15, 2024
c5a65f7
web: update PasswordStageForm according to lit-analyzer
kensternberg-authentik Jul 15, 2024
f4c8624
Another lit-analyze error found.
kensternberg-authentik Jul 15, 2024
a09afd3
Merge branch 'main' into web/cf/provide-show-password-button
kensternberg-authentik Jul 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions authentik/flows/tests/test_inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def test(self):
self.assertJSONEqual(
res.content,
{
"allow_show_password": False,
"component": "ak-stage-identification",
"flow_info": {
"background": flow.background_url,
Expand Down
3 changes: 2 additions & 1 deletion authentik/stages/identification/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ class IdentificationStage(Stage):
help_text=_(
(
"When set, shows a password field, instead of showing the "
"password field as seaprate step."
"password field as separate step."
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Genuinely surprised codespell didn't throw a fit here.

),
),
)

case_insensitive_matching = models.BooleanField(
default=True,
help_text=_("When enabled, user fields are matched regardless of their casing."),
Expand Down
3 changes: 3 additions & 0 deletions authentik/stages/identification/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class IdentificationChallenge(Challenge):

user_fields = ListField(child=CharField(), allow_empty=True, allow_null=True)
password_fields = BooleanField()
allow_show_password = BooleanField(default=False)
application_pre = CharField(required=False)
flow_designation = ChoiceField(FlowDesignation.choices)

Expand Down Expand Up @@ -197,6 +198,8 @@ def get_challenge(self) -> Challenge:
"primary_action": self.get_primary_action(),
"user_fields": current_stage.user_fields,
"password_fields": bool(current_stage.password_stage),
"allow_show_password": bool(current_stage.password_stage)
and current_stage.password_stage.allow_show_password,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't normally argue with black but, man, that is ugly.

"show_source_labels": current_stage.show_source_labels,
"flow_designation": self.executor.flow.designation,
}
Expand Down
2 changes: 2 additions & 0 deletions authentik/stages/password/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Meta:
"backends",
"configure_flow",
"failed_attempts_before_cancel",
"allow_show_password",
]


Expand All @@ -28,6 +29,7 @@ class PasswordStageViewSet(UsedByMixin, ModelViewSet):
"name",
"configure_flow",
"failed_attempts_before_cancel",
"allow_show_password",
]
search_fields = ["name"]
ordering = ["name"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 5.0.6 on 2024-07-02 18:14

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("authentik_stages_password", "0008_replace_inbuilt"),
]

operations = [
migrations.AddField(
model_name="passwordstage",
name="allow_show_password",
field=models.BooleanField(
default=False,
help_text="When enabled, provides a 'show password' button with the password input field.",
),
),
]
6 changes: 6 additions & 0 deletions authentik/stages/password/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ class PasswordStage(ConfigurableStage, Stage):
"To lock the user out, use a reputation policy and a user_write stage."
),
)
allow_show_password = models.BooleanField(
default=False,
help_text=_(
"When enabled, provides a 'show password' button with the password input field."
),
)

@property
def serializer(self) -> type[BaseSerializer]:
Expand Down
10 changes: 8 additions & 2 deletions authentik/stages/password/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from django.urls import reverse
from django.utils.translation import gettext as _
from rest_framework.exceptions import ValidationError
from rest_framework.fields import CharField
from rest_framework.fields import BooleanField, CharField
from sentry_sdk.hub import Hub
from structlog.stdlib import get_logger

Expand Down Expand Up @@ -76,6 +76,8 @@

component = CharField(default="ak-stage-password")

allow_show_password = BooleanField(default=False)


class PasswordChallengeResponse(ChallengeResponse):
"""Password challenge response"""
Expand Down Expand Up @@ -134,7 +136,11 @@
response_class = PasswordChallengeResponse

def get_challenge(self) -> Challenge:
challenge = PasswordChallenge(data={})
challenge = PasswordChallenge(

Check warning on line 139 in authentik/stages/password/stage.py

View check run for this annotation

Codecov / codecov/patch

authentik/stages/password/stage.py#L139

Added line #L139 was not covered by tests
data={
"allow_show_password": self.executor.current_stage.allow_show_password,
}
)
recovery_flow = Flow.objects.filter(designation=FlowDesignation.RECOVERY)
if recovery_flow.exists():
recover_url = reverse(
Expand Down
7 changes: 6 additions & 1 deletion blueprints/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -6905,7 +6905,7 @@
"password_stage": {
"type": "integer",
"title": "Password stage",
"description": "When set, shows a password field, instead of showing the password field as seaprate step."
"description": "When set, shows a password field, instead of showing the password field as separate step."
},
"case_insensitive_matching": {
"type": "boolean",
Expand Down Expand Up @@ -7207,6 +7207,11 @@
"maximum": 2147483647,
"title": "Failed attempts before cancel",
"description": "How many attempts a user has before the flow is canceled. To lock the user out, use a reputation policy and a user_write stage."
},
"allow_show_password": {
"type": "boolean",
"title": "Allow show password",
"description": "When enabled, provides a 'show password' button with the password input field."
}
},
"required": []
Expand Down
28 changes: 25 additions & 3 deletions schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29993,6 +29993,10 @@ paths:
operationId: stages_password_list
description: PasswordStage Viewset
parameters:
- in: query
name: allow_show_password
schema:
type: boolean
- in: query
name: configure_flow
schema:
Expand Down Expand Up @@ -37067,6 +37071,9 @@ components:
nullable: true
password_fields:
type: boolean
allow_show_password:
type: boolean
default: false
application_pre:
type: string
flow_designation:
Expand Down Expand Up @@ -37149,7 +37156,7 @@ components:
format: uuid
nullable: true
description: When set, shows a password field, instead of showing the password
field as seaprate step.
field as separate step.
case_insensitive_matching:
type: boolean
description: When enabled, user fields are matched regardless of their casing.
Expand Down Expand Up @@ -37217,7 +37224,7 @@ components:
format: uuid
nullable: true
description: When set, shows a password field, instead of showing the password
field as seaprate step.
field as separate step.
case_insensitive_matching:
type: boolean
description: When enabled, user fields are matched regardless of their casing.
Expand Down Expand Up @@ -40953,6 +40960,9 @@ components:
type: string
recovery_url:
type: string
allow_show_password:
type: boolean
default: false
required:
- pending_user
- pending_user_avatar
Expand Down Expand Up @@ -41235,6 +41245,10 @@ components:
minimum: -2147483648
description: How many attempts a user has before the flow is canceled. To
lock the user out, use a reputation policy and a user_write stage.
allow_show_password:
type: boolean
description: When enabled, provides a 'show password' button with the password
input field.
required:
- backends
- component
Expand Down Expand Up @@ -41271,6 +41285,10 @@ components:
minimum: -2147483648
description: How many attempts a user has before the flow is canceled. To
lock the user out, use a reputation policy and a user_write stage.
allow_show_password:
type: boolean
description: When enabled, provides a 'show password' button with the password
input field.
required:
- backends
- name
Expand Down Expand Up @@ -42092,7 +42110,7 @@ components:
format: uuid
nullable: true
description: When set, shows a password field, instead of showing the password
field as seaprate step.
field as separate step.
case_insensitive_matching:
type: boolean
description: When enabled, user fields are matched regardless of their casing.
Expand Down Expand Up @@ -42804,6 +42822,10 @@ components:
minimum: -2147483648
description: How many attempts a user has before the flow is canceled. To
lock the user out, use a reputation policy and a user_write stage.
allow_show_password:
type: boolean
description: When enabled, provides a 'show password' button with the password
input field.
PatchedPermissionAssignRequest:
type: object
description: Request to assign a new permission
Expand Down
15 changes: 10 additions & 5 deletions web/src/admin/stages/password/PasswordStageForm.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { RenderFlowOption } from "@goauthentik/admin/flows/utils";
import { BaseStageForm } from "@goauthentik/admin/stages/BaseStageForm";
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
import { first } from "@goauthentik/common/utils";
import "@goauthentik/components/ak-switch-input.js";
import "@goauthentik/elements/forms/FormGroup";
import "@goauthentik/elements/forms/HorizontalFormElement";
import "@goauthentik/elements/forms/SearchSelect";

import { msg } from "@lit/localize";
import { TemplateResult, html } from "lit";
import { customElement } from "lit/decorators.js";
import { ifDefined } from "lit/directives/if-defined.js";

import {
BackendsEnum,
Expand Down Expand Up @@ -72,10 +71,10 @@ export class PasswordStageForm extends BaseStageForm<PasswordStage> {
return html` <span>
${msg("Validate the user's password against the selected backend(s).")}
</span>
<ak-form-element-horizontal label=${msg("Name")} ?required=${true} name="name">
<ak-form-element-horizontal label=${msg("Name")} required name="name">
<input
type="text"
value="${ifDefined(this.instance?.name || "")}"
value="${this.instance?.name || ""}"
class="pf-c-form-control"
required
/>
Expand Down Expand Up @@ -158,7 +157,7 @@ export class PasswordStageForm extends BaseStageForm<PasswordStage> {
>
<input
type="number"
value="${first(this.instance?.failedAttemptsBeforeCancel, 5)}"
value="${this.instance?.failedAttemptsBeforeCancel ?? 5}"
class="pf-c-form-control"
required
/>
Expand All @@ -168,6 +167,12 @@ export class PasswordStageForm extends BaseStageForm<PasswordStage> {
)}
</p>
</ak-form-element-horizontal>
<ak-switch-input
name="allowShowPassword"
label="Allow Show Password"
?checked=${this.instance?.allowShowPassword ?? false}
help=${msg("Provide users with a 'show password' button.")}
></ak-switch-input>
</div>
</ak-form-group>`;
}
Expand Down
Loading
Loading