How to set access permissions and user roles in GitLab
How to set access permissions and user roles in GitLab
GitLab is a powerful open source code hosting platform that not only helps teams easily manage and collaborate on code development , and also provides flexible access permissions and user role settings. In this article, we'll explore how to set access permissions and user roles in GitLab, and provide specific code examples for reference.
1. Set user roles
In GitLab, user roles are mainly divided into four levels: Owner, Maintainer, Developer and Guest. Owner is a role with full administrative rights and can control project settings and user permissions; Maintainer can manage projects and members, and edit project code; Developer can view, edit, and submit project code; Guest can only view code and issues, etc.
To create a user role through the API, you can use the access token provided by GitLab to authorize:
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/users/<user_id>/project_members" { "id": "<id>", "user_id": <user_id>, "project_id": <project_id>, "access_level": <access_level> }
Among them, <your_access_token>
is the access token and needs to be replaced with Your own token; <user_id>
is the user ID, representing the user whose role is to be set; <project_id>
is the project ID, representing the project for which the role is to be set; <access_level>
is the access level, which can be 40
(Owner), 30
(Maintainer), 20
(Developer) or One of 10
(Guest).
2. Set access permissions
In GitLab, permissions are divided into system level and project level. System-level permissions control the functions and access scope of the entire GitLab, while project-level permissions control the access and operations of specific projects.
- System-level permissions
To set system-level permissions, you need to use an administrator account or a user with Admin permissions. To update system-level permissions through the API, you can use the following code example:
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/application/settings" --data "signup_enabled=false&default_project_visibility=private"
Among them, signup_enabled
indicates whether the user is allowed to register, and the default is true
; default_project_visibility
represents the default visibility of new projects, which can be one of private
, internal
or public
.
- Project-level permissions
To set project-level permissions, you need to use the project's administrator account or a user with Maintainer permissions. To update project-level permissions through the API, you can use the following code example:
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/<project_id>/members/<user_id>" --data "access_level=30"
Where, <project_id>
is the project ID, representing the project for which permissions are to be set; <user_id>
is the user ID, representing the user whose permissions are to be set; access_level
is the access level, which can be 0
(Guest), 10
(Reporter), # One of ##20 (Developer),
30 (Maintainer) or
40 (Owner).
The above is the detailed content of How to set access permissions and user roles in GitLab. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



GitLab is a version management and collaboration tool for developers. Its historical versions allow users to easily retrieve previous code. Sometimes we may accidentally update a wrong code, or accidentally delete some files. At this time, we need to restore to a previous version in order to start working again. This article mainly introduces how to restore to the previous version number on GitLab.

GitLab is a web-based Git version control library management software designed to help development teams work better together and improve work efficiency. When you log in to GitLab for the first time, you will be prompted to change your initial password to ensure account security. This article will introduce how to log in for the first time and change the password on GitLab.

This article is about learning Gitlab, talking about how to set up a protected branch and submit a PR to your leader. I hope it will be helpful to everyone!

How to use GitLab for project document management 1. Background introduction In the software development process, project documents are very important information. They can not only help the development team understand the needs and design of the project, but also provide reference to the testing team and customers. In order to facilitate version control and team collaboration of project documents, we can use GitLab for project document management. GitLab is a version control system based on Git. In addition to supporting code management, it can also manage project documents. 2. GitLab environment setup First, I

1. Download the gitlab installation package. Download the latest Chinese version of the gitlab installation package from [Tsinghua University Open Source Software Mirror Station]. The installation package comes with a simplified Chinese localization package. Download the latest gitlab installation package from [gitlab official website]. 2. Install gitlab, take gitlab-ce-14.9.4-ce.0.el7.x86_64 as an example, upload it to the centos server and use yum to install gitlabyum-yinstallgitlab-ce-14.3.2-ce.0.el7.x86_64. rpm uses yum to install gityum-yinstallgit#Install git and modify the gitlab configuration file vi

Installation first requires installing the python-gitlab library pip installation sudopip install --upgradepython-gitlab source code installation gitclone https://github.com/python-gitlab/python-gitlabcdpython-gitlabsudopythonsetup.pyinstall Usage CLI Usage First, you need to configure the environment to use cli. You need to provide a configuration file to indicate gitlabserver information and connection parameters. The configuration file format is INI. The sample is as follows: [global]defau

Maybe you have encountered such a problem. A program or software downloaded from the App Store in Windows 10 system cannot be found and opened after closing the App Store. The following is a detailed solution. Steps for accessing the WindowsApps folder in win10: 1. First find the folder named "WindowsApps" in the explorer and right-click on this folder. 2. Then select the "Properties" option, and in the "WindowsApps Properties" dialog box, switch to the "Security" option. 3. You can see the list of security permissions currently granted to the folder. Click the "Advanced" button to expand more details. 4. In "Advanced Security Settings for Windows Apps - Change -

Downloading the code on the GitLab server locally allows you to modify and manage the code more conveniently. This article will introduce how to download the code on the GitLab server to local.
