Home  >  Article  >  Java  >  How to implement springboot permission management function

How to implement springboot permission management function

PHPz
PHPzforward
2023-05-11 10:22:132104browse

Function list

  • 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.

Function introduction

Next we will introduce the permission management function and demonstrate a complete permission management process.

Menu management

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;

How to implement springboot permission management function

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;

How to implement springboot permission management function

Menu sorting, after setting the sorting of the menu, the menu will be sorted according to the setting Display in descending order.

How to implement springboot permission management function

Resource Management

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;

How to implement springboot permission management function

Add and edit resources, here we have added a concept of resource classification to facilitate future resource allocation;

How to implement springboot permission management function

Role Management

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;

How to implement springboot permission management function

Add and edit roles Used to manage the basic attributes of roles;

How to implement springboot permission management function

Assignment menu, you can assign menus that allow access to roles;

How to implement springboot permission management function

To allocate resources, you can assign background resources that are allowed to be accessed to roles;

How to implement springboot permission management function

Background user management

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;

How to implement springboot permission management function

Add and edit users, you can manage the user's basic information and modify the password;

How to implement springboot permission management function

# Assign roles. Users can be assigned roles. Users with designated roles can access designated menus and resources.

How to implement springboot permission management function

Dynamic menu control

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:

How to implement springboot permission management function

Use the product administrator account to log in, and only product-related menus are displayed on the left:

How to implement springboot permission management function

Dynamic resource control

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;

How to implement springboot permission management function

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.

How to implement springboot permission management function

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!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete