fix user update permission (#11603)

This commit is contained in:
hth 2024-01-11 17:16:00 +08:00 committed by GitHub
parent 207505735c
commit a7d1c35f85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -176,12 +176,18 @@ public class UserController {
}
IdentityContext identityContext = (IdentityContext) request.getSession()
.getAttribute(com.alibaba.nacos.plugin.auth.constant.Constants.Identity.IDENTITY_CONTEXT);
NacosUser user;
if (identityContext == null
|| (user = (NacosUser) identityContext.getParameter(AuthConstants.NACOS_USER_KEY)) == null
|| (user = iAuthenticationManager.authenticate(request)) == null) {
if (identityContext == null) {
throw new HttpSessionRequiredException("session expired!");
}
NacosUser user = (NacosUser) identityContext.getParameter(AuthConstants.NACOS_USER_KEY);
if (user == null) {
user = iAuthenticationManager.authenticate(request);
if (user == null) {
throw new HttpSessionRequiredException("session expired!");
}
//get user form jwt need check permission
iAuthenticationManager.hasGlobalAdminRole(user);
}
// admin
if (user.isGlobalAdmin()) {
return true;