Skip to content

Commit

Permalink
providers/oauth2: improve indexes on tokens (#11543)
Browse files Browse the repository at this point in the history
  • Loading branch information
rissson authored Sep 27, 2024
1 parent 4af2be8 commit 4a5058d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Generated by Django 5.0.9 on 2024-09-27 14:50

from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("authentik_providers_oauth2", "0019_accesstoken_authentik_p_token_4bc870_idx_and_more"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.RemoveIndex(
model_name="accesstoken",
name="authentik_p_token_4bc870_idx",
),
migrations.RemoveIndex(
model_name="refreshtoken",
name="authentik_p_token_1a841f_idx",
),
migrations.AddIndex(
model_name="accesstoken",
index=models.Index(fields=["token", "provider"], name="authentik_p_token_f99422_idx"),
),
migrations.AddIndex(
model_name="refreshtoken",
index=models.Index(fields=["token", "provider"], name="authentik_p_token_a1d921_idx"),
),
]
4 changes: 2 additions & 2 deletions authentik/providers/oauth2/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ class AccessToken(SerializerModel, ExpiringModel, BaseGrantModel):

class Meta:
indexes = [
models.Index(fields=["token"]),
models.Index(fields=["token", "provider"]),
]
verbose_name = _("OAuth2 Access Token")
verbose_name_plural = _("OAuth2 Access Tokens")
Expand Down Expand Up @@ -423,7 +423,7 @@ class RefreshToken(SerializerModel, ExpiringModel, BaseGrantModel):

class Meta:
indexes = [
models.Index(fields=["token"]),
models.Index(fields=["token", "provider"]),
]
verbose_name = _("OAuth2 Refresh Token")
verbose_name_plural = _("OAuth2 Refresh Tokens")
Expand Down

0 comments on commit 4a5058d

Please sign in to comment.