JWT is an great way to make sure the data send to the user and back is not tampered with, but that makes for some tough choices. At the moment I am in the dilemma of choosing between storing the authorization data in an JWT claim and only touch the database once for the authorization, or just store the user ID and check the authorization levels on each request to the server with the database.
What makes this such a hard choice is that the application works with multiple authorization levels which makes the base64 encoded url quite long and bulky (see below what can be expected to be stored as authorization levels).
On the other hand, to get the authorization, two lookups in the database are necessary.
So my question is as following; Is the extra overhead on each request by sending the permissions to the server worth avoiding the hassle of looking up the permissions upon each request?
As an sidenote; In the case of permission changes the look-up-in-the-database approach has the benefit of not requiring the user to log in again (see post).
"perms": {
"roles": [
{
"name": "Admin",
"id": 1,
"assigned": true
},
{
"name": "Webmaster",
"id": 8,
"assigned": true
}
],
"actions": [
{
"id": 1,
"name": "cms-edit",
"parameters": null,
"parameterized": null
},
{
"id": 9,
"name": "admin-syslog",
"parameters": null,
"parameterized": null
},
{
"id": 10,
"name": "admin-debug",
"parameters": null,
"parameterized": null
},
{
"id": 12,
"name": "member-list-extended",
"parameters": null,
"parameterized": null
},
{
"id": 2,
"name": "cms-list",
"parameters": null,
"parameterized": null
},
{
"id": 3,
"name": "cms-add",
"parameters": null,
"parameterized": null
},
{
"id": 5,
"name": "member-list",
"parameters": null,
"parameterized": null
},
{
"id": 7,
"name": "member-view",
"parameters": null,
"parameterized": null
},
{
"id": 8,
"name": "member-edit",
"parameters": null,
"parameterized": null
}
]