Skip to content

Commit

Permalink
Add missing permissiong check on UserServiceImpl
Browse files Browse the repository at this point in the history
Signed-off-by: Claudio Mezzasalma <claudio.mezzasalma@eurotech.com>
  • Loading branch information
Claudio Mezzasalma authored and Coduz committed May 5, 2020
1 parent 35bb08d commit cec2ca6
Showing 1 changed file with 18 additions and 2 deletions.
Expand Up @@ -226,7 +226,15 @@ public User findByName(String name) throws KapuaException {

//
// Do the find
return entityManagerSession.onResult(em -> checkReadAccess(UserDAO.findByName(em, name)));
User user = entityManagerSession.onResult(em -> checkReadAccess(UserDAO.findByName(em, name)));

//
// Check Access
if (user != null) {
authorizationService.checkPermission(permissionFactory.newPermission(UserDomains.USER_DOMAIN, Actions.read, user.getScopeId()));
}

return user;
}

@Override
Expand All @@ -237,7 +245,15 @@ public User findByExternalId(String externalId) throws KapuaException {

//
// Do the find
return entityManagerSession.onResult(em -> checkReadAccess(UserDAO.findByExternalId(em, externalId)));
User user = entityManagerSession.onResult(em -> checkReadAccess(UserDAO.findByExternalId(em, externalId)));

//
// Check Access
if (user != null) {
authorizationService.checkPermission(permissionFactory.newPermission(UserDomains.USER_DOMAIN, Actions.read, user.getScopeId()));
}

return user;
}

@Override
Expand Down

0 comments on commit cec2ca6

Please sign in to comment.