essential
Essential
Startups & Small Teams – Manage risk early by securing non-human identities from day one.
If you need to grant a specific group access to multiple projects simultaneously (instead of using a group access token from a parent group), you can use the script below. This is less common than the Group Access Token method described above.
-------------------
$ pip install requests
-------------------
• Save the script below as 'invite_group_to_all_visible_repositories.py':
-------------------
import sys
import re
import json
from requests import post, get
host = sys.argv[1]
token = sys.argv[2]
group_name = sys.argv[3]
if(host.endswith("/")):
host = host[:-1]
headers = {
"Authorization": f"Bearer {token}"
}
def get_groups():
response = get(f"{host}/api/v4/groups?search={group_name}", headers=headers)
return response.json()
groups = get_groups()
print(json.dumps(groups))
name_matched_groups = [group for group in groups if group["name"] == group_name]
if len(name_matched_groups) == 0:
print(f"couldn't find group that has name {group_name}")
sys.exit(1)
group = name_matched_groups[0]
group_name = group["name"]
payload = {
"group_access": 10,
"group_id": group["id"]
}
NEXT_PAGE_PATTERN = re.compile("<(.+)>; rel=\"next\"")
def get_projects():
projects = []
response = get(f"{host}/api/v4/projects?order_by=id&sort=asc", headers=headers)
projects.extend(response.json())
if "Link" in response.headers:
match_result = NEXT_PAGE_PATTERN.search(response.headers["Link"])
if(match_result):
next_page_url = match_result[1]
else:
next_page_url = None
else:
next_page_url = None
while next_page_url:
response = get(next_page_url, headers=headers)
if "Link" in response.headers:
match_result = NEXT_PAGE_PATTERN.search(response.headers["Link"])
if(match_result):
next_page_url = match_result[1]
else:
next_page_url = None
else:
next_page_url = None
projects.extend(response.json())
return projects
for project in get_projects():
project_id = project["id"]
project_name = project["name"]
share_proejct_endpoint = host + f"/api/v4/projects/{project_id}/share"
response = post(share_proejct_endpoint, json=payload, headers=headers)
if response.status_code == 201:
print(f"proejct {project_name} is shared with group {group_name}")</(.+)>
-------------------
-------------------
$ python invite_group_to_all_visible_repositories.py {GitLab_host} {user_access_token} {group_name_to_invite}
-------------------
• After running the script, check a few projects under Project>Manage>Members>Groups tab to confirm the target group has been added with the specified role.
Need help with this integration? Please Contact Us, and we'll be happy to assist.
Startups & Small Teams – Manage risk early by securing non-human identities from day one.
Custom Solutions – Secure non-human identities at scale, across complex environments.
Aenean lobortis, massa a imperdiet iaculis, lorem odio lacinia elit, non hendrerit ligula justo tempor lorem.
We provide detailed documentation for the integration processes, and dedicated customer support to assist with integrations, troubleshooting, and remediation strategies on paid versions. For more information or to get started, visit our website or contact our support team.
Cremit provides an automated, SaaS-based detection solution that scans your code repositories for non-human identities (NHI) such as API keys, tokens, passwords, certificates, and others to help prevent data breaches and security incidents.
Vulnerable NHIs can expose your systems to unauthorized access, data leaks, and compliance violations. By using Cremit, you can continuously monitor and detect leaks early in the development cycle, reducing the risk of security breaches and ensuring your codebase remains secure.