mirror of
https://github.com/simple-login/app.git
synced 2024-09-27 20:31:30 +02:00
black
This commit is contained in:
parent
9fb91c83e7
commit
2b8febe0b9
@ -67,20 +67,24 @@ def fido_setup():
|
||||
current_user.fido_uuid = fido_uuid
|
||||
|
||||
FIDO.create(
|
||||
credential_id = str(fido_credential.credential_id, "utf-8"),
|
||||
uuid = fido_uuid,
|
||||
public_key = str(fido_credential.public_key, "utf-8"),
|
||||
sign_count = fido_credential.sign_count,
|
||||
credential_id=str(fido_credential.credential_id, "utf-8"),
|
||||
uuid=fido_uuid,
|
||||
public_key=str(fido_credential.public_key, "utf-8"),
|
||||
sign_count=fido_credential.sign_count,
|
||||
)
|
||||
db.session.commit()
|
||||
|
||||
LOG.d(f"credential_id={str(fido_credential.credential_id, 'utf-8')} added for {fido_uuid}")
|
||||
LOG.d(
|
||||
f"credential_id={str(fido_credential.credential_id, 'utf-8')} added for {fido_uuid}"
|
||||
)
|
||||
|
||||
flash("Security key has been activated", "success")
|
||||
return redirect(url_for("dashboard.recovery_code_route"))
|
||||
|
||||
# Prepare information for key registration process
|
||||
fido_uuid = str(uuid.uuid4()) if current_user.fido_uuid is None else current_user.fido_uuid
|
||||
fido_uuid = (
|
||||
str(uuid.uuid4()) if current_user.fido_uuid is None else current_user.fido_uuid
|
||||
)
|
||||
challenge = secrets.token_urlsafe(32)
|
||||
|
||||
credential_create_options = webauthn.WebAuthnMakeCredentialOptions(
|
||||
@ -102,11 +106,13 @@ def fido_setup():
|
||||
|
||||
# Prevent user from adding duplicated keys
|
||||
for record in fido_model:
|
||||
registration_dict["excludeCredentials"].append({
|
||||
'type': 'public-key',
|
||||
'id': record.credential_id,
|
||||
'transports': ['usb', 'nfc', 'ble', 'internal'],
|
||||
})
|
||||
registration_dict["excludeCredentials"].append(
|
||||
{
|
||||
"type": "public-key",
|
||||
"id": record.credential_id,
|
||||
"transports": ["usb", "nfc", "ble", "internal"],
|
||||
}
|
||||
)
|
||||
|
||||
session["fido_uuid"] = fido_uuid
|
||||
session["fido_challenge"] = challenge.rstrip("=")
|
||||
|
@ -119,13 +119,19 @@ class AliasGeneratorEnum(EnumE):
|
||||
word = 1 # aliases are generated based on random words
|
||||
uuid = 2 # aliases are generated based on uuid
|
||||
|
||||
|
||||
class FIDO(db.Model, ModelMixin):
|
||||
__tablename__ = "fido"
|
||||
credential_id = db.Column(db.String(), nullable=False, unique=True, index=True)
|
||||
uuid = db.Column(db.ForeignKey("users.fido_uuid", ondelete="cascade"), unique=False, nullable=False)
|
||||
uuid = db.Column(
|
||||
db.ForeignKey("users.fido_uuid", ondelete="cascade"),
|
||||
unique=False,
|
||||
nullable=False,
|
||||
)
|
||||
public_key = db.Column(db.String(), nullable=False, unique=True)
|
||||
sign_count = db.Column(db.Integer(), nullable=False)
|
||||
|
||||
|
||||
class User(db.Model, ModelMixin, UserMixin):
|
||||
__tablename__ = "users"
|
||||
email = db.Column(db.String(256), unique=True, nullable=False)
|
||||
|
16
server.py
16
server.py
@ -148,16 +148,16 @@ def fake_data():
|
||||
db.session.commit()
|
||||
|
||||
FIDO.create(
|
||||
credential_id = "umR9q5vX61XG7vh7gi8wT0gJ9LkYwHKSzDL5vhtZs3o",
|
||||
uuid = "59576167-6c37-4d67-943b-4683b24ff821",
|
||||
public_key = "pQECAyYgASFYIEjQg3TOuUZJxylLE6gJDNHcNyYVW5hOAZ-vGOY9I_TDIlggfJqIh07bj3n6RVmrEsuozsYPYM6VeJKCeduz0DFp8AY",
|
||||
sign_count = 1,
|
||||
credential_id="umR9q5vX61XG7vh7gi8wT0gJ9LkYwHKSzDL5vhtZs3o",
|
||||
uuid="59576167-6c37-4d67-943b-4683b24ff821",
|
||||
public_key="pQECAyYgASFYIEjQg3TOuUZJxylLE6gJDNHcNyYVW5hOAZ-vGOY9I_TDIlggfJqIh07bj3n6RVmrEsuozsYPYM6VeJKCeduz0DFp8AY",
|
||||
sign_count=1,
|
||||
)
|
||||
FIDO.create(
|
||||
credential_id = "1mR9q5vX61XG7vh7gi8wT0gJ9LkYwHKSzDL5vhtZs3o",
|
||||
uuid = "59576167-6c37-4d67-943b-4683b24ff821",
|
||||
public_key = "1QECAyYgASFYIEjQg3TOuUZJxylLE6gJDNHcNyYVW5hOAZ-vGOY9I_TDIlggfJqIh07bj3n6RVmrEsuozsYPYM6VeJKCeduz0DFp8AY",
|
||||
sign_count = 1,
|
||||
credential_id="1mR9q5vX61XG7vh7gi8wT0gJ9LkYwHKSzDL5vhtZs3o",
|
||||
uuid="59576167-6c37-4d67-943b-4683b24ff821",
|
||||
public_key="1QECAyYgASFYIEjQg3TOuUZJxylLE6gJDNHcNyYVW5hOAZ-vGOY9I_TDIlggfJqIh07bj3n6RVmrEsuozsYPYM6VeJKCeduz0DFp8AY",
|
||||
sign_count=1,
|
||||
)
|
||||
db.session.commit()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user