Skip to content

Commit 55aef46

Browse files
authored
Documentation for service accounts (#1184)
Adds some documentation for service accounts, how to create them, manage them, add permissions, etc.
1 parent 884dc9a commit 55aef46

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed

docs/admin/access_control/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ You can read about the specific permission types available for each RBAC-enabled
4242

4343
- [Batch Changes](/admin/access_control/batch_changes)
4444
- [Ownership](/admin/access_control/ownership)
45+
- [Service accounts](/admin/access_control/service_accounts)
4546

4647
### Deleting a role
4748

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Service Accounts
2+
3+
Service accounts are specialized user accounts designed for automation, API integrations, and programmatic access to Sourcegraph, as opposed to using access tokens from regular users. Unlike regular user accounts, service accounts don't require an email address or password, cannot access the Sourcegraph UI, don't count towards a license's user limit and won't be part of any billing cycles.
4+
5+
## Creating Service Accounts
6+
7+
Service accounts are created like regular user accounts, but with a few key differences.
8+
9+
- Go to **Site admin****Users & auth****Users**
10+
- Click **Create User**
11+
- Enter a descriptive **Username** (e.g., `ci-bot-scip-uploads`, `api-search-jobs`)
12+
- Check the **Service account** checkbox
13+
- Click **Create service account**
14+
15+
You'll be presented with some next steps you might want to take, like creating an access token, managing and assigning roles, and managing repository permissions.
16+
17+
- Service accounts are automatically assigned the "Service Account" system role
18+
- They appear in the user list with "Service account" type designation
19+
- By default, service accounts can only access public and unrestricted repositories
20+
21+
## Managing Access Tokens
22+
23+
Service accounts authenticate using access tokens rather than passwords. For detailed information about creating, managing, and using access tokens, see:
24+
25+
- [Creating an access token](/cli/how-tos/creating_an_access_token)
26+
- [Managing access tokens](/cli/how-tos/managing_access_tokens)
27+
- [Revoking an access token](/cli/how-tos/revoking_an_access_token)
28+
29+
Use service account access tokens to access Sourcegraph's [GraphQL API](/api/graphql).
30+
31+
## Role-Based Access Control (RBAC)
32+
33+
Service accounts integrate with Sourcegraph's [role-based access control](/admin/access_control) to provide fine-grained permission control.
34+
35+
### System Roles
36+
37+
Service accounts are automatically assigned the **Service Account** system role, which provides basic API access permissions and standard search capabilities. The **Service Account** system role is applied to all service accounts and can be used to provide service accounts with a default set of permissions. For more specialized service accounts, it is recommended to create custom roles and assign them to service accounts as needed.
38+
39+
### Managing Roles
40+
41+
Administrators can assign additional roles to service accounts through the user management interface. For detailed information on managing roles and permissions, see:
42+
43+
- [Managing roles and permissions](/admin/access_control#managing-roles-and-permissions)
44+
- [Managing user roles](/admin/access_control#managing-user-roles)
45+
- [Creating custom roles](/admin/access_control#creating-a-new-role-and-assigning-it-permissions)
46+
47+
## Repository Permissions
48+
49+
Service accounts respect repository permissions and access controls. For comprehensive information about repository permissions, see the [Repository permissions](/admin/permissions) documentation.
50+
51+
Service accounts by default can only access public and unrestricted repositories in Sourcegraph. You may explicitly grant fine-grained access to private repositories from the service account's user settings page, under the **Repo permissions** tab, or via [the GraphQL API](/admin/permissions/api#explicit-permissions-api). In the **Repo permissions** tab, you can also grant service accounts access to all current and future repositories on Sourcegraph, regardless of their visibility, which is useful for service accounts that need to do things like perform search jobs, but admins should take care to ensure that the access tokens for these accounts are not shared with unauthorized users.

docs/admin/auth/index.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ The following methods are supported for sign up and sign in:
2929

3030
The authentication providers are configured in the [`auth.providers`](/admin/config/site_config#authentication-providers) site configuration option.
3131

32+
## Programmatic authentication
33+
34+
For automated systems, CI/CD pipelines, and API integrations that need to authenticate without human interaction, use [service accounts](/admin/access_control/service_accounts). Service accounts are specialized user accounts designed for automation that authenticate using access tokens rather than passwords.
35+
3236
## Login form configuration
3337

3438
To configure the presentation of the login form, see the [login form configuration page](/admin/auth/login_form).

docs/api/graphql/index.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ You should see a response like this:
3232
{ "data": { "currentUser": { "username": "YOUR_USERNAME" } } }
3333
```
3434

35+
For automated scripts, CI/CD pipelines, and production integrations, use [service accounts](/admin/access_control/service_accounts) instead of personal access tokens. Service accounts are designed specifically for programmatic API access and provide better security and audit capabilities.
36+
3537
## Documentation & tooling
3638

3739
### API Console

0 commit comments

Comments
 (0)