Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use spring security for user role management?

I need to design a user role management module for online examine tool application, There are several users in the system (Admin, Moderator, Contributor, Examiner). These users have different privileges for the system. I need to use the Spring framework and spring security for the user access system. How do I use the spring security for this module. Can anyone direct me to a good tutorial and your ideas allways welcome.

like image 640
zlas Avatar asked Aug 21 '12 06:08

zlas


People also ask

How do I check my Spring Security role?

The first way to check for user roles in Java is to use the @PreAuthorize annotation provided by Spring Security. This annotation can be applied to a class or method, and it accepts a single string value that represents a SpEL expression. Before we can use this annotation, we must first enable global method security.

Which class in Spring Security framework is used to define role?

The UserDetailsService is a core interface in Spring Security framework, which is used to retrieve the user's authentication and authorization information. This interface is also responsible to provide the User's GrantedAuthority list, which is used to derive our spring security roles and permissions for the user.

Which code snippet in Spring Security configure that user page is accessible by the user role?

“/userPage” is used by USER Role to access and perform Normal user activities. “/adminPage” is used by ADMIN Role to access and perform Admin user activities. ADMIN role can access “/userPage” URL too.


2 Answers

Based on your description, I think that you might be looking at a custom implementation of UserDetailsService.
It's worth checking out Stephan Gerth's ZK sample project, that integrates Spring, Hibernate, customized Spring security, ZK Ajax, etc. Here you have the announcement post, that has links to source and documentation. I suggest reading the chapter 13.2. Spring-Security (and related), that should help you navigate the source code.

like image 114
Less Avatar answered Sep 26 '22 20:09

Less


Try this one Spring Authorization and Authentication.A very simple tutorial for beginners.

like image 30
user1613360 Avatar answered Sep 22 '22 20:09

user1613360