简体   繁体   English

如何在 Flutter Web 客户端本地存储令牌

[英]How do you store a token locally on a flutter web client

Say you get a token from server after logging in. I want the flutter web app to resume without the user logging in again, so I want to store something locally.假设您在登录后从服务器获取令牌。我希望 Flutter Web 应用程序在用户再次登录的情况下恢复,所以我想在本地存储一些东西。 There are packages that you can store the token locally to HTML localstorage, but it can be easily revealed using chrome developer tools.有些包可以将令牌本地存储到 HTML localstorage,但可以使用 chrome 开发人员工具轻松显示。 SecurePreference doesn't have a web version. SecurePreference 没有网络版本。 Some packages stores in Indexed DB, but it suffers from the same problem.一些包存储在索引数据库中,但它遇到了同样的问题。 They can also be revealed by simple chrome developer tools.它们也可以通过简单的 chrome 开发人员工具显示出来。

Yes, you can store an encrypted version of the token to somewhere, but then where do you store the key?是的,您可以将令牌的加密版本存储到某个地方,但是您将密钥存储在哪里? It will be stupid to store the key right next to the encrypted token.将密钥存储在加密令牌旁边是愚蠢的。

You can use shared_preferences from pub.dev.您可以使用 pub.dev 中的 shared_preferences。 Used for local storage in all the platform.用于所有平台的本地存储。 https://pub.dev/packages/shared_preferences https://pub.dev/packages/shared_preferences

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

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