简体   繁体   English

如何正确设置 Django 的密码?

[英]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.我正在尝试将 Passkeys 应用于 Django 项目,但我对这两个项目都是新手,并且遇到了困难。

So following instructions I found here on how to add Passkeys I'm supposed to the following code to my settings.py file:因此,按照我在此处找到的有关如何添加密码的说明,我应该将以下代码添加到我的settings.py文件中:

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. NONE不是 Python 中的关键字,所以我尝试使用None但这给了我一个TypeError: unsupported operand type(s) for *: 'NoneType' and 'AuthenticatorAttachment'错误。

Also thought I am using localhost for my server ID, I'm not sure what to add for my authentication backend.还以为我使用localhost作为我的服务器 ID,我不确定要为我的身份验证后端添加什么。

What am I missing?我错过了什么?

Thanks!谢谢!

You don't need to use None for KEY_ATTACHMENT at all.您根本不需要为KEY_ATTACHMENT使用None 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:根据您的项目在settings.py模块中对KEY_ATTACHMENT配置的需求,您应该具有如下配置:

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.此外,您可以在django-passkeys项目的示例项目中看到配置。

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.此外,基于此项目中的此导入,如果您看到AuthenticatorAttachment [python-fido2 ]对象,您会发现此设置只有两个上述配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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