Uploaded image for project: 'Bitbucket Server'
  1. Bitbucket Server
  2. BSERV-7265

Allow sysadmins to view orphaned repositories in Stash

    XMLWordPrintable

    Details

    • Type: Suggestion
    • Status: Gathering Interest (View Workflow)
    • Resolution: Unresolved
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Feedback Policy:
      We collect Bitbucket feedback from various sources, and we evaluate what we've collected when planning our product roadmap. To understand how this piece of feedback will be reviewed, see our Implementation of New Features Policy.

      Description

      Summary

      From this post in Answers we found a use case in which users that are removed from Stash or deactivated in an external User Directory might leave orphan personal repositories behind that are not accessible from the UI.

      We should offer sysadmins a way to view these orphaned personal repositories so they can be managed.

      Steps to Reproduce

      Here is the scenario. I, the administrator, create a user. The user logs in and creates some repositories and only gives himself/herself access to said repositories.
      The user is now fired and the administrator (actually the LDAP synchronization task) removes the user from Stash. How does the administrator find all of the repositories that the user created?
      When I run this test, the repositories just seem to disappear. I have to know the names of the repositories to search for them and then I can add a new owner or delete them.
      I work for a large organization and this scenario could lead to many orphaned repositories, because the administrator is not privy to every employee departure and certainly would not know what repositories were created by the user.

      Scenario 1: Internal Database

      1. Create a user in the Stash Internal Database
      2. Add at least Global permissions to it
      3. Log in as the newly created user
      4. Go to its profile and create a personal repo
      5. As an admin user, delete the user
      6. You will have created an orphan repo

      Scenario 2: External Directory

      1. Create a user in the External Directory you've got (i.e. LDAP, Crowd or JIRA)
      2. Add at least Global permissions to it
      3. Log in as the newly created user
      4. Go to its profile and create a personal repo
      5. As an admin of the User Directory, de-activate the user
      6. You will have created an orphan repo

      Expected Results

      The repo will still be there, but the Stash administrator will have a way to easily find repos on that situation.

      Actual Results

      The repo will still be there, but the Stash administrator will have a way to easily find repos on that situation.

      This ties back to STASH-3564 as there should be a better way to visualize/browse personal repositories

      Workaround

      You will be able to find the orphan users/repos if you run the query below against your database:

      select snu.name, r.slug from sta_personal_project spr, repository r, sta_normal_user snu
      where spr.project_id=r.project_id and spr.owner_id=snu.user_id 
      and snu.name not in 
      (select u.lower_user_name 
      from cwd_user u join cwd_directory d on u.directory_id = d.id 
      where d.is_active='T' and u.is_active='T');
      

      Important: do not change anything on your database. With the information above, as a Stash administrator, you will be able to hit the orphan profile page of that user and remove its repo. You will have to browse straight into their profile page by hitting the following URL:

      http://<Stash_URL>/users/<username_from_query_above>
      

      On this page you will be able to see all the user's orphan repos. From there, you can browse into the repo "Settings" and delete the repo on the top right button of the next screen.

      If you need the deletion to be done in bulk, you can programmatically do it using the DELETE method using curl, for example, calling this REST API in Stash.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned
              Reporter:
              tbomfim Thiago Bomfim
              Votes:
              71 Vote for this issue
              Watchers:
              60 Start watching this issue

                Dates

                Created:
                Updated: