TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: Do you store permissions in a JWT?

1 点作者 zacksinclair超过 5 年前
If you store your permissions in your JWT, how do you handle changing permissions?<p>Is the overhead of a database query for permissions worth the security gain of instantly able to change permissions? (IE use JWT for authentication, check permissions for authorization on each request)<p>What is the general consensus these days on handling permissions WRT JWTs?

1 comment

ilkhan4超过 5 年前
If the number of possible permissions is small enough, sure. Otherwise it ends up being a huge token that gets sent over the wire for each request.<p>One &quot;hybrid&quot; approach that seems to work well is pulling permissions from the DB but then caching them in-memory on the server. That way you can still keep them granular but you&#x27;ll only hit the DB on the first request or if the cache expires. It also lets you immediately kill access (rather than waiting for the JWT to expire) if you can send a message to your servers to clear the cache for that user.
评论 #21029580 未加载