我正在使用 JWT api ,我使用以下方法生成了一个 token :
public void addAuthentication(HttpServletResponse response, String name) {
// We generate a token now.
String JWT = Jwts.builder()
.setSubject(name)
.signWith(SignatureAlgorithm.HS512, secret)
.compact();
response.addHeader(headerString, tokenPrefix + " " + JWT);
}
abd secret token 前缀是 string ,但是它确实生成 token ,但是当我将其复制到
它确实对它进行了解码并显示了其中存储的所有信息,我是否做错了什么或者它应该是什么?这看起来一点也不安全。
谢谢各位的解答
最佳答案
这是非常安全的。别担心。只需以安全的方式存储您的 key 即可。 值得注意的是,没有 key 就无法更改解码后的信息或无法生成 token 。
避免在 token 中存储重要信息,例如信用卡号或密码等。我确信您不会将 JWT 用于此目的。
If you want to hide the payload, the JWT specification allows use encryption (see Json Web Encryption-JWE at RFC). If auth0 does not support it, you have a lot of libraries listed in jwt.io
检查此主题
关于java - JWT 在其网站上很容易被解码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42651052/