-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add transports to backup cred See merge request locker/api-core!446
- Loading branch information
Showing
15 changed files
with
107 additions
and
11 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
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 |
---|---|---|
@@ -1,10 +1,21 @@ | ||
from rest_framework import serializers | ||
|
||
from locker_server.shared.constants.backup_credential import LIST_CREDENTIAL_TYPE, CREDENTIAL_TYPE_HMAC | ||
from locker_server.shared.constants.backup_credential import LIST_CREDENTIAL_TYPE, CREDENTIAL_TYPE_HMAC, \ | ||
WEBAUTHN_VALID_TRANSPORTS | ||
|
||
|
||
class PasswordlessCredentialSerializer(serializers.Serializer): | ||
credential_id = serializers.CharField(max_length=255) | ||
random = serializers.CharField(max_length=64, required=False, allow_null=True, allow_blank=True) | ||
transports = serializers.ListSerializer( | ||
child=serializers.CharField(max_length=64, required=True), required=False, allow_empty=True, allow_null=True | ||
) | ||
name = serializers.CharField(max_length=255, allow_blank=False) | ||
type = serializers.ChoiceField(choices=LIST_CREDENTIAL_TYPE, required=False, default=CREDENTIAL_TYPE_HMAC) | ||
|
||
def validate(self, data): | ||
transports = data.get("transports") | ||
if transports and not any(valid_transport in transports for valid_transport in WEBAUTHN_VALID_TRANSPORTS): | ||
raise serializers.ValidationError(detail={"transports": ["The transports is not valid"]}) | ||
data["transports"] = ",".join(transports) if transports else None | ||
return data |
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
23 changes: 23 additions & 0 deletions
23
locker_server/api_orm/migrations/0024_auto_20240528_1045.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,23 @@ | ||
# Generated by Django 3.2.23 on 2024-05-28 03:45 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('api_orm', '0023_auto_20240403_1446'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='backupcredentialorm', | ||
name='fd_transports', | ||
field=models.CharField(blank=True, default=None, max_length=255, null=True), | ||
), | ||
migrations.AddField( | ||
model_name='userorm', | ||
name='fd_transports', | ||
field=models.CharField(blank=True, default=None, max_length=255, null=True), | ||
), | ||
] |
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
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
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 |
---|---|---|
@@ -1,4 +1,16 @@ | ||
from webauthn.helpers.structs import AuthenticatorTransport | ||
|
||
|
||
BACKUP_CREDENTIAL_MAX = 6 | ||
CREDENTIAL_TYPE_HMAC = "hmac" | ||
CREDENTIAL_TYPE_PRF = "prf" | ||
LIST_CREDENTIAL_TYPE = [CREDENTIAL_TYPE_PRF, CREDENTIAL_TYPE_HMAC] | ||
|
||
|
||
WEBAUTHN_VALID_TRANSPORTS = [ | ||
AuthenticatorTransport.USB, | ||
AuthenticatorTransport.NFC, | ||
AuthenticatorTransport.BLE, | ||
AuthenticatorTransport.HYBRID, | ||
AuthenticatorTransport.INTERNAL, | ||
] |
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 |
---|---|---|
|
@@ -68,4 +68,6 @@ geoip2==4.7.0 | |
pandas==2.2.1 | ||
|
||
notion-client==2.2.1 | ||
httpx==0.27.0 | ||
httpx==0.27.0 | ||
|
||
webauthn==1.11.1 |