Menu management: It can manage the left menu of the background management system, support changing icons, changing names, and controlling menu display and sorting;
Resource management: realizes background dynamic permission control based on access paths, and the controlled permissions can be accurate to the interface level;
Role management: roles can be customized, And assign menus and resources to roles;
Backend user management: You can manage backend users and assign roles, and support the assignment of multiple roles.
Next we will introduce the permission management function and demonstrate a complete permission management process.
The menu mainly refers to the menu on the left side of the management background. The management function can be used to control its hidden display and change the name and sorting of pictures. Currently, only the secondary menu is supported.
View the menu list, you can control the hiding, display and deletion;
Add and edit the menu, you can change the basic properties of the menu, but you can only add front-end items The menu defined in the routing, and the front-end name must be consistent with the routing name defined in the front-end project;
Menu sorting, after setting the sorting of the menu, the menu will be sorted according to the setting Display in descending order.
The so-called resource is the backend interface, which can be a single interface or a collection of a series of interfaces. Here we use Ant-based path matching. When a background user accesses an interface, the resource can be accessed if the background user has allocated it, otherwise it cannot be accessed. By default, if you do not configure a resource for an interface, the resource directly allows access.
View the resource list, the current resources are configured at the controller level, that is, all interfaces in a controller are defined as one resource, and can also be configured to the interface level;
Add and edit resources, here we have added a concept of resource classification to facilitate future resource allocation;
Used to manage background user roles. We can assign specified menus and resources to roles, so that background users assigned roles can access these menus and resources.
View the role list, here we need to pay attention to the three roles of product administrator, order administrator and super administrator;
Add and edit roles Used to manage the basic attributes of roles;
Assignment menu, you can assign menus that allow access to roles;
To allocate resources, you can assign background resources that are allowed to be accessed to roles;
is used to manage background users and directly modify information (including Change password) and assign roles.
View the user list, you can control the activation status of the account and delete the account;
Add and edit users, you can manage the user's basic information and modify the password;
# Assign roles. Users can be assigned roles. Users with designated roles can access designated menus and resources.
Here we will demonstrate the control of the dynamic menu. We have two background users, the system administrator and the product administrator. The system The administrator assigns all menus, and the product administrator assigns only product-related menus.
Use the system administrator account to log in, and all menus are displayed on the left:
Use the product administrator account to log in, and only product-related menus are displayed on the left:
Here we will demonstrate the control of dynamic resources. We only assign product-related resources to the product administrator, and he cannot access other resources.
The order-related menu is opened to the product administrator, but order-related resources are not assigned to him;
Because the product administrator is not assigned an order Module-related background resources, so when the product administrator accesses the order module, it will prompt that he does not have relevant permissions.
The above is the detailed content of How to implement springboot permission management function. For more information, please follow other related articles on the PHP Chinese website!