概述
本文中建立在认证流程的基础上,所以建议读者先看看认证文章
demo
首先来看表设计
大体流程该如图所示,写好doGetAuthorizationInfo也就好了
doGetAuthorizationInfo代码
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
String username = JWTUtil.getUsername(principals.toString());
AuthUser user =
authUserService.getOne(new QueryWrapper<AuthUser>().lambda().eq(AuthUser::getName, username));
SimpleAuthorizationInfo simpleAuthorizationInfo = new SimpleAuthorizationInfo();
simpleAuthorizationInfo.addRoles(authUserService.findUserRoles