简体   繁体   中英

How to properly set Passkeys for Django?

I'm trying to apply Passkeys to a Django project, but I'm new to both and am finding difficulties.

So following instructions I found here on how to add Passkeys I'm supposed to the following code to my settings.py file:

AUTHENTICATION_BACKENDS = \['passkeys.backend.PasskeyModelBackend'\] # Change your authentication backend
FIDO_SERVER_ID="localhost"      # Server rp id for FIDO2, it the full domain of your project
FIDO_SERVER_NAME="MTGStore"
import passkeys
KEY_ATTACHMENT = NONE | passkeys.Attachment.CROSS_PLATFORM | passkeys.Attachment.PLATFORM

NONE is not a keyword in Python though, so I've tried using None but that gave me a TypeError: unsupported operand type(s) for *: 'NoneType' and 'AuthenticatorAttachment' error.

Also thought I am using localhost for my server ID, I'm not sure what to add for my authentication backend.

What am I missing?

Thanks!

You don't need to use None for KEY_ATTACHMENT at all. Based on what you need for your project for the KEY_ATTACHMENT config in your settings.py module, you should have sth like below configs:

KEY_ATTACHMENT = passkeys.Attachment.PLATFORM

or

KEY_ATTACHMENT = passkeys.Attachment.CROSS_PLATFORM

Also, you can see this config in the example project here in django-passkeys project.

In addition based on this import in this project, if you see AuthenticatorAttachment [python-fido2 ] object you'll find out you have just two above configs for this setting.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM