使用JWT(?)对具有持久性的电子应用的用户进行身份验证
我希望使用用户凭据(用户名 +密码)保护我的电子桌面应用程序,但是我很难找到合适的技术。要求:
- 可以确定激活的数量(例如,可以在任何给定时间激活该应用程序的副本)
- 用户可以远程停用/撤销对所有活动实例的访问。
- 如果用户不远程注销,则无需无限地将激活的副本手动重新验证。
- 例如,用户可以自己对自己进行身份验证,而不是长时间使用桌面应用程序,那么当他们重新打开时不会再次登录。
我目前正在寻找JWT,因为它有点满足2。但是我已经读到,建议代币不会保存在数据库中,因此,如果我需要黑名单令牌,那么黑名单将是一个永远增长的收藏,这不是理想的选择(除非您有一个Cronjob可以删除已过期的令牌)
我不确定哪种解决方案在这里是满足要求的理想选择。
I'm looking to secure my electron desktop app with user credentials (username + password), but I'm having a hard time finding the right technology to use. Requirements:
- Number of activations can be determined (e.g. x copies of the app can be activated at any given time)
- The user can deactivate/revoke access to all active instances remotely.
- The activated copy will not need to be re-authenticated manually indefinitely if the user does not log out remotely.
- For example, the user can authenticate themself, not use the desktop app for a long time then they aren't expected to log in again when they re-open it.
I am currently looking at JWT as it somewhat satisifes 2. However i've read that it's advised that the tokens not be saved in a database, so if I need to blacklist tokens, the blacklist would be a forever growing collection which is not ideal (unless you had a cronjob to remove expired tokens)
I'm not sure which solution would be ideal here that would meet the requirements.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用JWT。创建两个令牌:访问令牌和刷新令牌。访问令牌将是短暂的(分钟),刷新令牌将是长寿(小时,天,几周)。遵循令牌处理中的最佳实践(访问令牌和刷新令牌最佳实践?还符合OWASP ASVS V3关于会话处理的要求,
您实际上确实希望刷新令牌到期。否则,您将需要永远将它们保留在某个黑名单中。永远很长。必须从存储中删除过期的日志是一个很小的代价来支付您愿意实施的这种灵活性。
使刷新令牌具有两个附加属性:
以便用户知道他是哪个代币无效。您将将唯一标识符和到期日期放入黑名单。
您可以根据主动访问令牌计数确定使用了多少个应用程序副本。
Use JWT. Create two tokens: access token and refresh token. The access token will be short-lived (minutes), the refresh token will be long-lived (hours, days, weeks). Follow the best practice in token handling (Access token and Refresh token best practices ? How to implement Access & Refresh Tokens). Also comply with the OWASP ASVS V3 requirements regarding session handling
You actually do want the refresh token to expire. Else you would need to hold them in some blacklist forever. Forever is pretty long. Having to delete the expired logs from storage is a small price to pay for this level of flexibility you are willing to implement.
Make the refresh token hold two additional attributes:
so the user knows which tokens he is invalidating. You would put into the blacklist the unique identifier and the expiration date.
You can identify how many copies of the application are being used based on the active access token count.