[英]Python Django DRF API one time session/token/pass authentication without a username/password
I have a Django and django rest framework project where I want a mobile to be able to request a token and then use that token for x minutes before they're disconnected. 我有一个Django和django rest框架项目,我希望移动设备能够请求令牌,然后在断开连接前先使用该令牌x分钟。 I do not want to create a user for each mobile device, I just want a one time password.
我不想为每个移动设备创建一个用户,我只想要一个一次性密码。
I tried using the auth system built into drf, however it required a user. 我尝试使用内置在drf中的身份验证系统,但是它需要一个用户。
So I was thinking about just using the onetimepass package to generate a one time token. 因此,我正在考虑仅使用onetimepass软件包来生成一次性令牌。
You can create a view that generates a time-based OTP and then use it in a custom auth module to authenticate against a single user. 您可以创建一个生成基于时间的OTP的视图,然后在自定义身份验证模块中使用它来针对单个用户进行身份验证。 You can also use JWT with an expiry time to authenticate against a single user.
您还可以将JWT与到期时间一起使用,以针对单个用户进行身份验证。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.