F
F
fecowab9722022-02-08 13:19:25
JSON Web Token
fecowab972, 2022-02-08 13:19:25

How to make a Middleware for JWT Authentication?

The problem is that in all the guides, they simply decode the token and check for validity. But the problem remains that one token has access to everything. For example, DELETE:username. I, using one token, can delete any user, because there is no :username parameter check and no username stigma.

I don’t know how to implement middleware, because I use different parameters in different endpoints and groups (not only :username), and in some I also need to check the glue username with json. field

Maybe I'm tricky and you need to remove the parameters, and send the data from the stigma with the username further along the equations.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
gelerum, 2022-02-08
@gelerum

Divide into several middleware. First check the token and extract the username, then pass this username to the parameter check, then to json, etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question