-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(backend): force token expire (#969)
* chore(token): token always expires Signed-off-by: Thibault Camalon <135698225+thbcmlowk@users.noreply.github.com> * chore(migrations): alter bearer token expires at Signed-off-by: Thibault Camalon <135698225+thbcmlowk@users.noreply.github.com> * chore(changelog): update changelog Signed-off-by: Thibault Camalon <135698225+thbcmlowk@users.noreply.github.com> * chore(backend/users/migrations): alter bearertoken expires only if null Signed-off-by: Thibault Camalon <135698225+thbcmlowk@users.noreply.github.com> * fix(users/migrations): chain AlterField migration operation Signed-off-by: Thibault Camalon <135698225+thbcmlowk@users.noreply.github.com> * tests(views/test_views_token): add expiring date and test case Signed-off-by: Thibault Camalon <135698225+thbcmlowk@users.noreply.github.com> * chore(users/migrations): field to models.DateTimeField() Signed-off-by: Thibault Camalon <135698225+thbcmlowk@users.noreply.github.com> * chore(users/models/token): blank=False instead of default value Signed-off-by: Thibault Camalon <135698225+thbcmlowk@users.noreply.github.com> * tests(test_views_token): add test cases Signed-off-by: Thibault Camalon <135698225+thbcmlowk@users.noreply.github.com> --------- Signed-off-by: Thibault Camalon <135698225+thbcmlowk@users.noreply.github.com>
- Loading branch information
Showing
5 changed files
with
57 additions
and
7 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
25 changes: 25 additions & 0 deletions
25
backend/users/migrations/0008_alter_bearertoken_expires_at.py
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,25 @@ | ||
# Generated by Django 4.2.5 on 2024-08-14 15:28 | ||
|
||
import django.utils.timezone | ||
from django.db import migrations | ||
from django.db import models | ||
|
||
|
||
def set_default_expires_at(apps, schema_editor): | ||
BearerToken = apps.get_model("users", "BearerToken") # noqa | ||
BearerToken.objects.filter(expires_at__isnull=True).update(expires_at=django.utils.timezone.now()) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("users", "0007_implicitbearertoken_id_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(set_default_expires_at), | ||
migrations.AlterField( | ||
model_name="bearertoken", | ||
name="expires_at", | ||
field=models.DateTimeField(), | ||
), | ||
] |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
Disable never expiring users `BearerToken` |