website/docs: update user object doc (#14132)
* Updated formatting, changed examples, added headers, updated django doc link to stable * Prettier fix * Update website/docs/users-sources/user/user_ref.mdx Co-authored-by: Marc 'risson' Schmitt <marc.schmitt@risson.space> Signed-off-by: Dewi Roberts <dewi@goauthentik.io> * Update website/docs/users-sources/user/user_ref.mdx Signed-off-by: Tana M Berry <tanamarieberry@yahoo.com> --------- Signed-off-by: Dewi Roberts <dewi@goauthentik.io> Signed-off-by: Tana M Berry <tanamarieberry@yahoo.com> Co-authored-by: Marc 'risson' Schmitt <marc.schmitt@risson.space> Co-authored-by: Tana M Berry <tanamarieberry@yahoo.com>
This commit is contained in:
@ -7,41 +7,43 @@ title: User properties and attributes
|
|||||||
The User object has the following properties:
|
The User object has the following properties:
|
||||||
|
|
||||||
- `username`: User's username.
|
- `username`: User's username.
|
||||||
- `email` User's email.
|
- `email`: User's email.
|
||||||
- `uid` User's unique ID
|
- `uid`: User's unique ID. Read-only.
|
||||||
- `name` User's display name.
|
- `name`: User's display name.
|
||||||
- `is_staff` Boolean field if user is staff.
|
- `is_staff`: Boolean field defining if user is staff.
|
||||||
- `is_active` Boolean field if user is active.
|
- `is_active`: Boolean field defining if user is active.
|
||||||
- `date_joined` Date user joined/was created.
|
- `date_joined`: Date user joined/was created. Read-only.
|
||||||
- `password_change_date` Date password was last changed.
|
- `password_change_date`: Date password was last changed. Read-only.
|
||||||
- `path` User's path, see [Path](#path)
|
- `path`: User's path, see [Path](#path)
|
||||||
- `attributes` Dynamic attributes, see [Attributes](#attributes)
|
- `attributes`: Dynamic attributes, see [Attributes](#attributes)
|
||||||
- `group_attributes()` Merged attributes of all groups the user is member of and the user's own attributes.
|
- `group_attributes()`: Merged attributes of all groups the user is member of and the user's own attributes. Ready-only.
|
||||||
- `ak_groups` This is a queryset of all the user's groups.
|
- `ak_groups`: This is a queryset of all the user's groups.
|
||||||
|
|
||||||
You can do additional filtering like:
|
|
||||||
|
|
||||||
```python
|
|
||||||
user.ak_groups.filter(name__startswith='test')
|
|
||||||
```
|
|
||||||
|
|
||||||
For Django field lookups, see [here](https://docs.djangoproject.com/en/4.2/ref/models/querysets/#id4).
|
|
||||||
|
|
||||||
To get the name of all groups, you can use this command:
|
|
||||||
|
|
||||||
```python
|
|
||||||
[group.name for group in user.ak_groups.all()]
|
|
||||||
```
|
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
List all the User's group names:
|
These are examples of how User objects can be used within Policies and Property Mappings.
|
||||||
|
|
||||||
|
### List a user's group memberships
|
||||||
|
|
||||||
|
Use the following example to list all groups that a User object is a member of:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
for group in user.ak_groups.all():
|
for group in user.ak_groups.all():
|
||||||
yield group.name
|
yield group.name
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### List a user's group memberships and filter based on group name
|
||||||
|
|
||||||
|
Use the following example to list groups that a User object is a member of, but filter based on group name:
|
||||||
|
|
||||||
|
```python
|
||||||
|
user.ak_groups.filter(name__startswith='test')
|
||||||
|
```
|
||||||
|
|
||||||
|
:::info
|
||||||
|
For Django field lookups, see the [Django documentation](https://docs.djangoproject.com/en/stable/ref/models/querysets/#id4).
|
||||||
|
:::
|
||||||
|
|
||||||
## Path
|
## Path
|
||||||
|
|
||||||
Paths can be used to organize users into folders depending on which source created them or organizational structure. Paths may not start or end with a slash, but they can contain any other character as path segments. The paths are currently purely used for organization, it does not affect their permissions, group memberships, or anything else.
|
Paths can be used to organize users into folders depending on which source created them or organizational structure. Paths may not start or end with a slash, but they can contain any other character as path segments. The paths are currently purely used for organization, it does not affect their permissions, group memberships, or anything else.
|
||||||
@ -87,7 +89,7 @@ This field is only used by the Proxy Provider.
|
|||||||
Some applications can be configured to create new users using header information forwarded from authentik. You can forward additional header information by adding each header
|
Some applications can be configured to create new users using header information forwarded from authentik. You can forward additional header information by adding each header
|
||||||
underneath `additionalHeaders`:
|
underneath `additionalHeaders`:
|
||||||
|
|
||||||
#### Example:
|
#### Example
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
additionalHeaders:
|
additionalHeaders:
|
||||||
|
Reference in New Issue
Block a user