core: customisable user settings (#2397)

* tenants: add user_settings flow, add basic flow and basic new executor

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>

* web/user: use flow PromptStage instead of custom stage

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>

* web/flows: add tenant to StageHost interface

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>

* web/user: fix form missing component

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>

* web/user: re-add success message

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>

* web/user: improve support for multiple error messages

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>

* stages/prompt: allow expressions in prompt placeholders

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>

* stages/prompt: add tests

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>

* flows: always set pending user

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>

* flows: never cache stage configuration flow plans

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>

* stages/user_write: fix error when pending user is anonymous user

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>

* web/admin: add checkbox for prompt placeholder expression

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>

* website/docs: add prompt expression docs

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>

* stages/prompt: add ak-locale field type

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>

* tenants: fix default policy

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>

* web/user: add function to do global refresh

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>

* web/flows: fix rendering of ak-locale

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>

* tenants: fix default policy, add error handling to placeholder, fix locale attribute

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>

* add tests

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens L
2022-03-03 00:13:06 +01:00
committed by GitHub
parent c57fbcfd89
commit 4f4f954693
41 changed files with 3791 additions and 2853 deletions

View File

@ -10,18 +10,31 @@ The prompt can be any of the following types:
| Type | Description |
| -------- | ----------------------------------------------------------------- |
| text | Arbitrary text. No client-side validation is done. |
| email | Email input. Requires a valid email address. |
| password | Password input. |
| number | Number input. Any number is allowed. |
| checkbox | Simple checkbox. |
| hidden | Hidden input field. Allows for the pre-setting of default values. |
| Text | Arbitrary text. No client-side validation is done. |
| Text (Read only) | Same as above, but cannot be edited. |
| Username | Same as text, except the username is validated to be unique. |
| Email | Text input, ensures the value is an email address (validation is only done client-side). |
| Password | Same as text, shown as a password field client-side, and custom validation (see below). |
| Number | Numerical textbox. |
| Checkbox | Simple checkbox. |
| Date | Same as text, except the client renders a date-picker |
| Date-time | Same as text, except the client renders a date-time-picker |
| Separator | Passive element to group surrounding elements |
| Hidden | Hidden input field. Allows for the pre-setting of default values. |
| Static | Display arbitrary value as is |
| authentik: Locale | Display a list of all locales authentik supports. |
Some types have special behaviors:
- *Username*: Input is validated against other usernames to ensure a unique value is provided.
- *Password*: All prompts with the type password within the same stage are compared and must be equal. If they are not equal, an error is shown
- *Hidden* and *Static*: Their placeholder values are defaults and are not user-changeable.
A prompt has the following attributes:
### `field_key`
The HTML name used for the prompt. This key is also used to later retrieve the data in expression policies:
The field name used for the prompt. This key is also used to later retrieve the data in expression policies:
```python
request.context.get('prompt_data').get('<field_key>')
@ -39,6 +52,11 @@ A flag which decides whether or not this field is required.
A field placeholder, shown within the input field. This field is also used by the `hidden` type as the actual value.
By default, the placeholder is interpreted as-is. If you enable *Interpret placeholder as expression*, the placeholder
will be evaluated as a python expression. This happens in the same environment as [_Property mappings_](../../../property-mappings/expression).
You can access both the HTTP request and the user as with a mapping. Additionally, you can access `prompt_context`, which is a dictionary of the current state of the prompt stage's data.
### `order`
The numerical index of the prompt. This applies to all stages which this prompt is a part of.