From 2cc5f4b27323792b0c553c8511e69a3dfaa798ab Mon Sep 17 00:00:00 2001 From: Dewi Roberts Date: Wed, 23 Apr 2025 08:26:10 +0100 Subject: [PATCH] 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 Signed-off-by: Dewi Roberts * Update website/docs/users-sources/user/user_ref.mdx Signed-off-by: Tana M Berry --------- Signed-off-by: Dewi Roberts Signed-off-by: Tana M Berry Co-authored-by: Marc 'risson' Schmitt Co-authored-by: Tana M Berry --- website/docs/users-sources/user/user_ref.mdx | 56 ++++++++++---------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/website/docs/users-sources/user/user_ref.mdx b/website/docs/users-sources/user/user_ref.mdx index b75d0bff2f..134139a7b2 100644 --- a/website/docs/users-sources/user/user_ref.mdx +++ b/website/docs/users-sources/user/user_ref.mdx @@ -7,41 +7,43 @@ title: User properties and attributes The User object has the following properties: - `username`: User's username. -- `email` User's email. -- `uid` User's unique ID -- `name` User's display name. -- `is_staff` Boolean field if user is staff. -- `is_active` Boolean field if user is active. -- `date_joined` Date user joined/was created. -- `password_change_date` Date password was last changed. -- `path` User's path, see [Path](#path) -- `attributes` Dynamic attributes, see [Attributes](#attributes) -- `group_attributes()` Merged attributes of all groups the user is member of and the user's own attributes. -- `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()] - ``` +- `email`: User's email. +- `uid`: User's unique ID. Read-only. +- `name`: User's display name. +- `is_staff`: Boolean field defining if user is staff. +- `is_active`: Boolean field defining if user is active. +- `date_joined`: Date user joined/was created. Read-only. +- `password_change_date`: Date password was last changed. Read-only. +- `path`: User's path, see [Path](#path) +- `attributes`: Dynamic attributes, see [Attributes](#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. ## 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 for group in user.ak_groups.all(): 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 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 underneath `additionalHeaders`: -#### Example: +#### Example ```yaml additionalHeaders: