How to prevent Logged in and anonymous users to view the Bamboo projects created automatically by Bamboo specs
Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
This article talks about how to change the permission of Logged in and anonymous users via REST API.
When we create Bamboo project via Bamboo specs the Logged in and Anonymous users are added as "view project" permissions automatically under Bamboo project permissions.
So as a workaround we can make use of the REST API calls first to remove the "view project" permission from the Project for Logged in and Anonymous users, and then add "view project " permission for Groups
Environment
This has been tested in Bamboo 8.0.9 but the solution will be applicable for any supported version.
Solution
We can use the below two Bamboo REST API to first remove the "view project" permission from the Project for Logged in and Anonymous users.
curl -X DELETE -u username:passwd -H "Content-Type: application/json" -d "[\"READ\"]" https://<BAMBOO-URL>/bamboo/rest/api/latest/permissions/project/{PROJKEY}/roles/LOGGED_IN
curl -X DELETE -u username:passwd -H "Content-Type: application/json" -d "[\"READ\"]" https://<BAMBOO-URL>/bamboo/rest/api/latest/permissions/project/{PROJKEY}/roles/ANONYMOUS
Post which you can use the below REST API to add "view project" permission for GROUP.
curl -X PUT -u username:passwd -H "Content-Type: application/json" -d "[\"READ\"]" https://<BAMBOO-URL>/bamboo/rest/api/latest/permissions/project/{PROJKEY}/groups/{groupname}