You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 5bffff6
Browse filesBrowse the repository at this point in the historyBrowse files
feat(search): update GitLab permission CSVs through the API (#9841)
* feat(search): update GitLab permission CSVs through the API
* fix(search): align GitLab CSV updates with CLI and API policies
* test(cli): cover confirmation for GitLab permission replacement
|`--expected-revision <value>`| Yes | Current permission revision obtained before generating this snapshot. |
292
+
|`--user-mapping <json\|@file>`| Yes | GitLab user IDs and their verified Sim email addresses. (JSON, or @path / @- to read a file or stdin). |
293
+
|`--project-permissions <json\|@file>`| Yes | GitLab project paths and the IDs of users granted access. (JSON, or @path / @- to read a file or stdin). |
294
+
|`-y, --yes`| Yes | Confirm this operation. |
295
+
296
+
</CommandTable>
297
+
298
+
API request and response schemas: [replaceGitLabSearchPermissions](/api-reference/organizations/replaceGitLabSearchPermissions).
|`--expected-revision <value>`| Yes | Current permission revision obtained before generating this snapshot. |
4349
+
|`--user-mapping <json\|@file>`| Yes | GitLab user IDs and their verified Sim email addresses. (JSON, or @path / @- to read a file or stdin). |
4350
+
|`--project-permissions <json\|@file>`| Yes | GitLab project paths and the IDs of users granted access. (JSON, or @path / @- to read a file or stdin). |
4351
+
|`-y, --yes`| Yes | Confirm this operation. |
4352
+
4353
+
</CommandTable>
4354
+
4355
+
API request and response schemas: [replaceGitLabSearchPermissions](/api-reference/organizations/replaceGitLabSearchPermissions).
4356
+
4291
4357
### sim organizations get
4292
4358
4293
4359
Get organization (OAuth login or personal API key required)
Copy file name to clipboardExpand all lines: apps/docs/content/docs/search/gitlab.mdx
+40-4Lines changed: 40 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,8 +11,8 @@ GitLab Search uses **Service account** mode, with one self-managed project per s
11
11
| --- | --- | --- |
12
12
| Token owner | Active instance administrator | Account that can read the project's content |
13
13
| PAT scopes |`read_api`; `admin_mode` when Admin Mode is enabled |`read_api`|
14
-
| Reader authorization | Current GitLab identity, membership, roles, and supported restrictions |Admin-uploaded email mapping and project grants |
15
-
| Membership changes | Checked during the request |Admin updates the CSV files|
14
+
| Reader authorization | Current GitLab identity, membership, roles, and supported restrictions |Email mapping and project grants supplied by your organization|
15
+
| Membership changes | Checked during the request |After the next successful CSV update|
16
16
| Confidential issues | Only when supported permissions allow the reader | Always excluded |
17
17
18
18
The administrator path requires self-managed GitLab 17.4 or later and its administrator identity/settings APIs. A project Maintainer or group Owner is not an instance administrator. Non-admin mode does not require those administrator APIs.
@@ -69,22 +69,58 @@ Use the full namespace path even if **Project** contains a numeric ID. Include i
69
69
- Use UTF-8 CSV, at most 4 MiB and 100,000 data rows per file. The full request must fit 10 MiB.
70
70
- Identical rows are deduplicated. Conflicting user-ID/email mappings and malformed rows are rejected.
71
71
72
-
These grants are admin-managed authorization. A granted reader can search allowed non-confidential content; Sim does not infer that person's actual GitLab role, restrictions, or membership from the non-admin token. Update both files when access changes.
72
+
In this example, Alice can search `engineering/platform` because the files link GitLab user `123` to both that project and `alice@example.com`. Sim checks that Alice is a current organization member and that her verified Sim email uniquely matches the grant. It checks again when she opens a result. GitLab receives the request under the source's read-only service account; Alice does not sign in to GitLab or authorize Sim individually.
73
+
74
+
Saving the CSVs grants the access listed in them. Changing a membership in GitLab alone does not change these grants. Replace the CSVs to add or revoke access; the change applies to the next search or read without re-indexing.
73
75
74
76
## Access checks
75
77
76
78
The source token retrieves content. Administrator mode proves the reader's current GitLab identity from verified Sim email, then checks project/group membership and policy during the request. Unsupported restrictions fail closed.
77
79
78
80
Non-admin mode uses saved source-local CSV grants and revalidates the token's current host/project identity. Confidential issues are excluded, including issues that became confidential after search.
79
81
80
-
Reads recheck current settings, permissions, and metadata. A reference from another member, account, organization, project, or host cannot authorize a read. Live Search does not use a stored content or permission index.
82
+
Reads recheck current settings, permissions, and metadata. A reference from another member, account, organization, project, or host cannot authorize a read. Sim fetches content live from GitLab. In CSV mode, Sim stores the uploaded mappings and resulting project grants.
81
83
82
84
## Update permissions or rotate the token
83
85
84
86
In project settings, replace either CSV file, retaining the other when appropriate. Sim validates the resulting pair before saving. Invalid or stale updates preserve saved grants. Removed readers lose access on the next operation.
85
87
86
88
To rotate the PAT, supply its replacement in source settings. A blank token retains the saved token. Changing host, project, or permission strategy requires valid configuration for the new identity.
87
89
90
+
### Automate updates with GitLab CI
91
+
92
+
After an admin configures a source in **Non-admin token** mode, a job can [read its revision](/api-reference/organizations/getGitLabSearchPermissions) and [replace both CSVs](/api-reference/organizations/replaceGitLabSearchPermissions). Copy `SIM_ORG_ID` and `SIM_SOURCE_ID` from the source settings URL: `/o/<organizationId>/settings/integrations/sources/<sourceId>`. Set `SIM_BASE_URL` to your Sim origin (for hosted Sim, `https://www.sim.ai`).
93
+
94
+
Store an organization admin's [personal Sim API key](/api-reference/authentication) as a [masked, protected GitLab CI variable](https://docs.gitlab.com/ci/variables/) named `SIM_API_KEY`. A personal key inherits its owner's access. This endpoint can only read the revision or replace both CSVs; it cannot change the GitLab PAT, host, or project.
95
+
96
+
This example runs on a schedule against a protected branch. Replace `./ci/export-gitlab-permissions` with your existing export command. It must write a fresh, complete `users.csv` and `project-permissions.csv` and exit nonzero if it cannot finish.
A successful update returns the new revision. A `409 Conflict` means someone updated the source after the job read its revision. Rerun the job from the beginning so it exports current grants. An invalid or header-only export leaves the previous grants in place. Alert on failed jobs so revocations aren't missed. If the project should have no readers, choose **Pause search** in the source settings. You can update the grants while the source is paused, then resume search when the grants are correct.
0 commit comments