diff --git a/authentik/providers/oauth2/migrations/0019_accesstoken_authentik_p_token_4bc870_idx_and_more.py b/authentik/providers/oauth2/migrations/0019_accesstoken_authentik_p_token_4bc870_idx_and_more.py new file mode 100644 index 0000000000..5e877bfbb5 --- /dev/null +++ b/authentik/providers/oauth2/migrations/0019_accesstoken_authentik_p_token_4bc870_idx_and_more.py @@ -0,0 +1,23 @@ +# Generated by Django 5.0.9 on 2024-09-26 16:25 + +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("authentik_providers_oauth2", "0018_alter_accesstoken_expires_and_more"), + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.AddIndex( + model_name="accesstoken", + index=models.Index(fields=["token"], name="authentik_p_token_4bc870_idx"), + ), + migrations.AddIndex( + model_name="refreshtoken", + index=models.Index(fields=["token"], name="authentik_p_token_1a841f_idx"), + ), + ] diff --git a/authentik/providers/oauth2/models.py b/authentik/providers/oauth2/models.py index 9484d98514..bab239d44d 100644 --- a/authentik/providers/oauth2/models.py +++ b/authentik/providers/oauth2/models.py @@ -376,6 +376,9 @@ class AccessToken(SerializerModel, ExpiringModel, BaseGrantModel): _id_token = models.TextField() class Meta: + indexes = [ + models.Index(fields=["token"]), + ] verbose_name = _("OAuth2 Access Token") verbose_name_plural = _("OAuth2 Access Tokens") @@ -419,6 +422,9 @@ class RefreshToken(SerializerModel, ExpiringModel, BaseGrantModel): _id_token = models.TextField(verbose_name=_("ID Token")) class Meta: + indexes = [ + models.Index(fields=["token"]), + ] verbose_name = _("OAuth2 Refresh Token") verbose_name_plural = _("OAuth2 Refresh Tokens")