Spring WEB Security: List of Available URLs

I am porting a web application to Spring Security. The application uses Spring MVC to render the JSP, and the controller methods are annotated using @Secured(...) .

So, at some point after successfully logging into the system and initializing the MVC servlet, some of the internal elements of Spring have this information: what permissions the user has (what permissions are granted), the URLs of the controllers, and the set of permissions required for each of them.

I want to dynamically get a list of URLs available for the current user to create a navigation bar.

Of course, I can override some Spring beans for this, but this approach seems too dirty. So, any suggestions on how to do this, possibly standard solutions?

+6
source share
1 answer

You can try using spring lib security tag in jsp, iterating over a list of controller urls

 <sec:authorize url="/admin"> This content will only be visible to users who are authorized to send requests to the "/admin" URL. </sec:authorize> 
+3
source

Source: https://habr.com/ru/post/947989/


All Articles