E
E
Eugenue Cesarevich2021-07-01 19:57:31
Java
Eugenue Cesarevich, 2021-07-01 19:57:31

Why are the annotations @PreAuthorize, @HasRole, etc. is it recommended to install in the service and not in the controller?

I met a recommendation that it is better to install security annotations on service methods, and not on the controller. On the one hand, this is logical (because the authorization logic is encapsulated in the service), but on the other hand, it is inconvenient - you have to go into the service in order to understand which role this or that controller method belongs to.

What is the reason why security annotations are recommended to be installed in the service?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Orkhan, 2021-07-01
@cot_shaurma

Good afternoon.
Here is a pretty good answer to your question:
https://stackoverflow.com/questions/14626969/shoul...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question