DefaultUserAccessor checks permissions before adding membership in 2.7 and later

XMLWordPrintable

    • Type: Bug
    • Resolution: Won't Fix
    • Priority: Medium
    • None
    • Affects Version/s: 2.7, 2.7.1, 2.7.2, 2.7.3, 2.8, 2.8.1
    • Component/s: None

      This issue has been created regarding Forum entry as well as a request from an user attempting to write a SSO authenticator

      I wrote an SSO authenticator that creates confluence users on the fly as they come to our confluence instance for the first time and at this time I assign them to groups based on their roles stored on our identity server. This was working fine until we upgraded to Confluence 2.7 where the addMembership() implementation was modified to check if the current user is an admin. Since the current user is the actual user that is logging in for the first time, the addMembership() call fails.

      The workaround for the above request would be to add the following two arguments to the addMemebership method:

      • group.getName()
      • user.getName();

      The DefaultUserAccessor implements UserAccessor inside the Bucket where permissions are checked inside the addMembership method.

      public void addMembership(Group group, User user)
          {
              if (!permissionManager.hasPermission(AuthenticatedUserThreadLocal.getUser(), Permission.EDIT, group))
                  throw new InsufficientPrivilegeException(AuthenticatedUserThreadLocal.getUsername());
      
              super.addMembership(group, user);
          }
      

      The implemented Confluence interface has two methods overwriting the default.

      public void addMembership(Group group, User user)
          {
              try
              {
                  getGroupManager().addMembership(group, user);
              }
              catch (EntityException e)
              {
                  log.error(e.getMessage());
              }
          }
      
          public void addMembership(String groupname, String username)
          {
              try
              {
                  Group group = getGroupManager().getGroup(groupname);
                  User user = getUserManager().getUser(username);
      
                  addMembership(group, user);
              }
              catch (EntityException e)
              {
                  log.error(e);
              }
          }
      

              Assignee:
              Unassigned
              Reporter:
              Ivan Benko [Atlassian]
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: