Controller methods that rely on JWT authentication using another service
Is there a way to handle these methods without writing so much duplicated code?
For example CRUD methods like this:
I need to repeat this chunk over and over in every method that relies on the JWT:
What other ways are there?
4 Replies
I tried making a custom Annotation to mark interceptor, but it didn't work; I registered the interceptor and everything ):
Why an interceptor? Seems a good fit for a normal actionfilter
or just write your own authenticationhandler and use
[Authorize]
Have you considered using middlewares? Implementing a custom middleware could be an ideal solution.
As Pobiega mentioned. Just use the Authorize attribute. If you need further checks then you can create your own Authorization attribute.