Uploaded image for project: 'Bitbucket Data Center'
  1. Bitbucket Data Center
  2. BSERV-7232

Javadoc for PermissionService should be more clear about anonymous user handling

    XMLWordPrintable

Details

    Description

      Developing a plugin which provides an alternative view on selected repository content, I used to check the file access permissions with

      permissionService.hasRepositoryPermission(stashUser, repository, Permission.REPO_READ)
      

      or

      permissionValidationService.validateForRepository(repository, Permission.REPO_READ);
      

      According to https://developer.atlassian.com/static/javadoc/stash/3.7.1/api/reference/com/atlassian/stash/user/PermissionService.html#hasRepositoryPermission(com.atlassian.stash.user.StashUser,%20com.atlassian.stash.repository.Repository,%20com.atlassian.stash.user.Permission) at least the first call should work for anonymous users if the repository is public. But it doesn't seem to work: Access was always denied for anonymous users.

      Please fix JavaDocs or implementation.

      I now use

      permissionService.isRepositoryAccessible(repository);
      

      which seem to work as expected. Is this the recommended use?

      Edit: Additionally I will have to write my own Condition to allow anonymous users access to public repositories, because

      <condition class="com.atlassian.stash.web.conditions.HasRepositoryPermissionCondition">
      	<param name="repository">$repository</param>
      	<param name="permission">REPO_READ</param>
      </condition>
      

      denies access for anonymous users.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              4d9c2a9b8369 resah
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: