简体   繁体   中英

How do I troubleshoot the current scenario for Authorize using JWT?

In my scenario I have a lot of action and a number of users. In the figure below, my methods can be accessed by examining what action each user has.

enter image description here

The number of these actions is about 2000 and is stored in the database. And every time you check the access to the method, you should search for the action that the user has in the database, and after the result is correct, the user can use the method. I used jwt for Authorize and after authenticating the user after logging in, a token was created for that user. In the token made for the user, one of my Claims is these actions.

enter image description here

Everything is working fine But I have two problems:

  1. The number of my actions is very high, about 2000 actions, now my users have about 60% to 70% of these actions or better to say they have access. Which should be included in the user's token, which seems unreasonable And my token volume increases.
  2. The second problem, according to the scenario I have, should be checked with each of these user accesses with the table in which I keep the actions, and in fact I have to run a query on the database, which reduces the performance.

Do you think there is a solution to those two problems?

One option is to do some smart caching of the tokens in the API and this video is a good introduction on how to achieve that in the API. Perhaps this can solve your problem.

Improving JWT performance in ASP.NET Core webinar with Mentor - Marcin Hoppe

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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