Skip to content

Commit c8f8a89

Browse files
mariotmariot-wedge
andauthored
Bump hashed_key max_length from 100 to 150 (#193)
* 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 <mariot.tsitoara@wedge-digital.com>
1 parent 1425544 commit c8f8a89

File tree

4 files changed

+69
-2
lines changed

4 files changed

+69
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Generated by Django 3.2.11 on 2022-01-10 11:02
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("rest_framework_api_key", "0004_prefix_hashed_key"),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name="apikey",
15+
name="hashed_key",
16+
field=models.CharField(editable=False, max_length=150),
17+
),
18+
migrations.AlterField(
19+
model_name="apikey",
20+
name="id",
21+
field=models.CharField(
22+
editable=False,
23+
max_length=150,
24+
primary_key=True,
25+
serialize=False,
26+
unique=True,
27+
),
28+
),
29+
]

src/rest_framework_api_key/models.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ class APIKeyManager(BaseAPIKeyManager):
7373
class AbstractAPIKey(models.Model):
7474
objects = APIKeyManager()
7575

76-
id = models.CharField(max_length=100, unique=True, primary_key=True, editable=False)
76+
id = models.CharField(max_length=150, unique=True, primary_key=True, editable=False)
7777
prefix = models.CharField(max_length=8, unique=True, editable=False)
78-
hashed_key = models.CharField(max_length=100, editable=False)
78+
hashed_key = models.CharField(max_length=150, editable=False)
7979
created = models.DateTimeField(auto_now_add=True, db_index=True)
8080
name = models.CharField(
8181
max_length=50,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Generated by Django 3.2.11 on 2022-01-10 11:02
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("heroes", "0003_alter_hero_id"),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name="heroapikey",
15+
name="hashed_key",
16+
field=models.CharField(editable=False, max_length=150),
17+
),
18+
migrations.AlterField(
19+
model_name="heroapikey",
20+
name="id",
21+
field=models.CharField(
22+
editable=False,
23+
max_length=150,
24+
primary_key=True,
25+
serialize=False,
26+
unique=True,
27+
),
28+
),
29+
]

test_project/project/settings.py

+9
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,15 @@
6969
{"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator"},
7070
]
7171

72+
# Password hashers
73+
74+
PASSWORD_HASHERS = [
75+
"django.contrib.auth.hashers.Argon2PasswordHasher",
76+
"django.contrib.auth.hashers.PBKDF2PasswordHasher",
77+
"django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher",
78+
"django.contrib.auth.hashers.BCryptSHA256PasswordHasher",
79+
]
80+
7281

7382
# Internationalization
7483

0 commit comments

Comments
 (0)