Remove VAPIDKeyset.public_key, generate on demand

Also rename `gen_vapid_keys` to `gen_vapid_key`, and merge migrations
This commit is contained in:
3wc
2021-04-07 17:06:40 +02:00
parent 6ac2905a6c
commit 64015d9b5b
5 changed files with 39 additions and 26 deletions

View File

@ -11,10 +11,8 @@ class Command(BaseCommand):
def handle(self, *args, **options):
priv_key = SigningKey.generate(curve=ecdsa.NIST256p)
pub_key = priv_key.get_verifying_key()
VAPIDKeyset.objects.create(
public_key=urlsafe_b64encode(b"\x04" + pub_key.to_string()).strip(b"="),
private_key=urlsafe_b64encode(priv_key.to_string()).strip(b"=")
)