Issue
I have an endpoint that I have to expose to all roles, whoever has at least one of the roles should get access to the api.
@PreAuthorize("hasAnyRole('ADMIN', 'USER')")
Now that the number of roles is increasing i have to add all the new roles to the API. Is there any way to expose everyone who have any role without specifying everyrole here? I am expecting something like this
@PreAuthorize("hasAnyValidRole()")
Solution
Finally got a quite easy solution.
@PreAuthorize("isAuthenticated()")
Answered By - mahfuj asif
Answer Checked By - Candace Johnson (JavaFixing Volunteer)