Skip to content

Commit

Permalink
Bump hashed_key max_length from 100 to 150 (#193)
Browse files Browse the repository at this point in the history
* bump hashed_key max_length from 100 to 150

* add migrations for hashed_key length extension

* linter files

* bump id length to 150

* add argon2 password hashers to heroes app

* run linter

Co-authored-by: Mariot <[email protected]>
  • Loading branch information
mariot and mariot-wedge authored Mar 2, 2022
1 parent 1425544 commit c8f8a89
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 2 deletions.
29 changes: 29 additions & 0 deletions src/rest_framework_api_key/migrations/0005_auto_20220110_1102.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Generated by Django 3.2.11 on 2022-01-10 11:02

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("rest_framework_api_key", "0004_prefix_hashed_key"),
]

operations = [
migrations.AlterField(
model_name="apikey",
name="hashed_key",
field=models.CharField(editable=False, max_length=150),
),
migrations.AlterField(
model_name="apikey",
name="id",
field=models.CharField(
editable=False,
max_length=150,
primary_key=True,
serialize=False,
unique=True,
),
),
]
4 changes: 2 additions & 2 deletions src/rest_framework_api_key/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ class APIKeyManager(BaseAPIKeyManager):
class AbstractAPIKey(models.Model):
objects = APIKeyManager()

id = models.CharField(max_length=100, unique=True, primary_key=True, editable=False)
id = models.CharField(max_length=150, unique=True, primary_key=True, editable=False)
prefix = models.CharField(max_length=8, unique=True, editable=False)
hashed_key = models.CharField(max_length=100, editable=False)
hashed_key = models.CharField(max_length=150, editable=False)
created = models.DateTimeField(auto_now_add=True, db_index=True)
name = models.CharField(
max_length=50,
Expand Down
29 changes: 29 additions & 0 deletions test_project/heroes/migrations/0004_auto_20220110_1102.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Generated by Django 3.2.11 on 2022-01-10 11:02

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("heroes", "0003_alter_hero_id"),
]

operations = [
migrations.AlterField(
model_name="heroapikey",
name="hashed_key",
field=models.CharField(editable=False, max_length=150),
),
migrations.AlterField(
model_name="heroapikey",
name="id",
field=models.CharField(
editable=False,
max_length=150,
primary_key=True,
serialize=False,
unique=True,
),
),
]
9 changes: 9 additions & 0 deletions test_project/project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@
{"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator"},
]

# Password hashers

PASSWORD_HASHERS = [
"django.contrib.auth.hashers.Argon2PasswordHasher",
"django.contrib.auth.hashers.PBKDF2PasswordHasher",
"django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher",
"django.contrib.auth.hashers.BCryptSHA256PasswordHasher",
]


# Internationalization

Expand Down

0 comments on commit c8f8a89

Please sign in to comment.