-
-
Notifications
You must be signed in to change notification settings - Fork 997
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jens Langhammer <[email protected]>
- Loading branch information
Showing
12 changed files
with
84 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Generated by Django 5.0.10 on 2025-01-08 17:39 | ||
|
||
from django.db import migrations | ||
from django.apps.registry import Apps | ||
from django.db.backends.base.schema import BaseDatabaseSchemaEditor | ||
|
||
|
||
def migrate_user_debug_attribute(apps: Apps, schema_editor: BaseDatabaseSchemaEditor): | ||
from django.apps import apps as real_apps | ||
from django.contrib.auth.management import create_permissions | ||
|
||
User = apps.get_model("authentik_core", "User") | ||
USER_ATTRIBUTE_DEBUG = "goauthentik.io/user/debug" | ||
|
||
# Permissions are only created _after_ migrations are run | ||
# - https://github.com/django/django/blob/43cdfa8b20e567a801b7d0a09ec67ddd062d5ea4/django/contrib/auth/apps.py#L19 | ||
# - https://stackoverflow.com/a/72029063/1870445 | ||
create_permissions(real_apps.get_app_config("authentik_core"), using=db_alias) | ||
|
||
Permission = apps.get_model("auth", "Permission") | ||
|
||
new_prem = Permission.objects.using(db_alias).get(codename="user_view_debug") | ||
|
||
db_alias = schema_editor.connection.alias | ||
for user in User.objects.using(db_alias).filter( | ||
**{f"attributes__{USER_ATTRIBUTE_DEBUG}": True} | ||
): | ||
user.permissions.add(new_prem) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("authentik_core", "0041_applicationentitlement"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterModelOptions( | ||
name="user", | ||
options={ | ||
"permissions": [ | ||
("reset_user_password", "Reset Password"), | ||
("impersonate", "Can impersonate other users"), | ||
("assign_user_permissions", "Can assign permissions to users"), | ||
("unassign_user_permissions", "Can unassign permissions from users"), | ||
("preview_user", "Can preview user data sent to providers"), | ||
("view_user_applications", "View applications the user has access to"), | ||
("user_view_debug", "User receives additional details for error messages"), | ||
], | ||
"verbose_name": "User", | ||
"verbose_name_plural": "Users", | ||
}, | ||
), | ||
migrations.RunPython(migrate_user_debug_attribute), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,9 @@ version = "2024.12.2" | |
description = "" | ||
authors = ["authentik Team <[email protected]>"] | ||
|
||
[tool.poetry.requires-plugins] | ||
poetry-plugin-export = ">1.8" | ||
|
||
[tool.black] | ||
line-length = 100 | ||
target-version = ['py312'] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters