A MatrixAuthDemo project is provided in GitHub project to show how to connect business application into MatrixAuth, which is under the demo
folder of the project.github home page of MatrixAuth
1 Function overview
Based on MatrixAuthClient, business application can complete some user and authority management work.
The work of MatrixAuthClient includes:
- User management: MatrixAuth is only responsible for managing permissions, not users. However, MatrixAuth needs to know the user’s addition and deletion information in order to maintain his permissions. When a business application adds or deletes users, it can notify MatrixAuth by calling related methods in MatrixAuthClient.
- “User-role” relationship management: there are some business related roles that must be granted or deprived by business applications, but MatrixAuth needs to be notified for permission management. The business application informs MatrixAuth of the operation that the user is given or deprived of the role through the relevant methods in MatrixAuthClient. Note that through the client, users can only be given or deprived of the roles of
businessappcontrolled
andinterfaceandbusinessappcontrolled
, but cannot be assigned the role ofinterfacecontrolled
. The interfacecontrolled role can only be edited through the interface provided by MatrixAuthClient.
2 Operation steps
Before using, import MatrixAuthClient,
@Autowired
private MatrixAuthClient matrixAuthClient;
2.1 Manage users
MatrixAuthClient provides three ways to manage users.
addUser(String userKey, String userName)
: Add one user to MatrixAuth.deleteUser(String userKey)
: Delete one user form MatrixAuth.updateUser(String userKey, String userName)
: Update one user in MatrixAuth.
2.2 Manage “user-role” relationship
The MatrixAuthClient provides the following three methods to manage the user role relationship.
addUserXRole(String userKey, String roleName)
:Add rolerolename
to the user whose key isuserkey
.deleteUserXRole(String userKey, String roleName)
:Delete the rolerolename
of the user whose key isuserkey
.