Skip to content

Commit 60c7891

Browse files
committed
Miscellaneous, need to clean this up
1 parent dba4a5e commit 60c7891

File tree

15 files changed

+129
-130
lines changed

15 files changed

+129
-130
lines changed

.editorconfig

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
root = true
2+
3+
[*]
4+
insert_final_newline = true
5+
end_of_line = lf
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
indent_style = space
9+
indent_size = 4
10+
11+
[{*.js,*.jsx,*.json,*.yml,*.yaml,*.md,.babelrc,.stylelintrc,*.proto}]
12+
indent_size = 2
13+
14+
[*.md]
15+
trim_trailing_whitespace = false
16+
17+
[{*.sh, *.bash}]
18+
indent_style = space
19+
indent_size = 2
20+
switch_case_indent = true
21+
22+
[**/node_modules/**]
23+
ignore = true

docs/admin/auth/index.mdx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ Leave the `url` field empty for GitHub.com.
102102

103103
Once you've configured GitHub as a sign-on provider, you may also want to [add GitHub repositories to Sourcegraph](/admin/code_hosts/github#repository-syncing).
104104

105-
106105
### How to control user sign-up and sign-in with GitHub auth provider
107106

108107
You can use the following filters to control how users will create accounts and sign in to your Sourcegraph instance via the GitHub auth provider.
@@ -116,7 +115,6 @@ The new user email, during their account creation, should match one of their Git
116115

117116
> WARNING: If `allowSignup` is set to `true`, anyone with internet access to both your Sourcegraph instance and your GitHub url are able to sign up and login to your instance. In particular, if url is set to `https://github.com`, this means that anyone with a Github account could log in to your Sourcegraph instance and search your indexed code. Make sure to also configure the `allowOrgs` field described below to limit sign-ups to your org, or limit public access to your Sourcegraph instance via IP restrictions / VPN. For assistance, contact support.
118117
119-
120118
```json
121119
{
122120
"type": "github",
@@ -533,3 +531,11 @@ Usernames from authentication providers are normalized before being used in Sour
533531
For example, a user whose external username (according the authentication provider) is `[email protected]` would have the Sourcegraph username `alice-smith`.
534532

535533
If multiple accounts normalize into the same username, separate accounts are still created, but Sourcegraph will add a randomized suffix to the username to ensure uniqueness.
534+
<<<<<<< Updated upstream
535+
=======
536+
537+
## Remind users to connect external accounts
538+
539+
When repository permissions are enabled, users must link their external code host accounts with their Sourcegraph accounts to access private repositories.
540+
To ensure users are aware of any unlinked accounts, users will be prompted to connect any missing external accounts upon visiting Sourcegraph for the first time, or when the provider configuration changes.
541+
>>>>>>> Stashed changes

docs/admin/auth/saml/azure_ad.mdx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@
44

55
1. In Microsoft Entra ID, create an unlisted (non-gallery) application [following the official documentation](https://docs.microsoft.com/en-us/azure/active-directory/manage-apps/add-non-gallery-app).
66
1. Once the application is created, follow [these instructions to enable SAML SSO](https://docs.microsoft.com/en-us/azure/active-directory/manage-apps/configure-single-sign-on-non-gallery-applications). Use these configuration values (replacing "sourcegraph.example.com" with your Sourcegraph instance URL):
7-
* **Identifier (Entity ID):** `https://sourcegraph.example.com/.auth/saml/metadata`
8-
* **Reply URL (Assertion Consumer Service URL):** `https://sourcegraph.example.com/.auth/saml/acs`
9-
* **Sign-on URL, Relay State, and Logout URL** can be left empty.
10-
* **User Attributes & Claims:** Add the following attributes.
11-
- `emailaddress`: user.mail (required)
12-
- `name`: user.userprincipalname (optional)
13-
- `login`: user.userprincipalname (optional)
14-
* **Name ID**: `email`
15-
* You can leave the other configuration values set to their defaults.
7+
- **Identifier (Entity ID):** `https://sourcegraph.example.com/.auth/saml/metadata`
8+
- **Reply URL (Assertion Consumer Service URL):** `https://sourcegraph.example.com/.auth/saml/acs`
9+
- **Sign-on URL** `https://sourcegraph.example.com/.auth/saml/login?pc=azure`
10+
- **Relay State, and Logout URL** can be left empty.
11+
- **User Attributes & Claims:** Add the following attributes.
12+
- `emailaddress`: user.mail
13+
- `name`: user.userprincipalname
14+
- `login`: user.userprincipalname
15+
- `Unique user identifier`: `user.objectid`
16+
- You can leave the other configuration values set to their defaults.
1617
1. Record the value of the "App Federation Metadata Url". You'll need this in the next section.
1718

1819
## 2. Add the SAML auth provider to Sourcegraph site config
@@ -27,10 +28,11 @@
2728
{
2829
"type": "saml",
2930
"configID": "azure",
30-
"identityProviderMetadataURL": "https://login.microsoftonline.com/7d2a00ed-73e8-4920-bbfa-ef68effe2d1e/federationmetadata/2007-06/federationmetadata.xml?appid=eff20ae4-145b-4bd3-ff3f-21edab43fe99"
31+
"identityProviderMetadataURL": "https://login.microsoftonline.com/7d2a00ed-73e8-4920-bbfa-ef68effe2d1e/federationmetadata/2007-06/federationmetadata.xml?appid=eff20ae4-145b-4bd3-ff3f-21edab43fe99",
32+
"allowSignup": true
3133
}
3234
]
3335
}
3436
```
3537

36-
> NOTE: Optional, but recommended: [add automatic provisioning of users with SCIM](/admin/scim).
38+
<Callout type="note">Optional, but recommended: [add automatic provisioning of users with SCIM](/admin/scim).</Callout>

docs/admin/auth/saml/okta.mdx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@
1111
- For “Single sign on URL”, set the value to `<URL>`/.auth/saml/acs
1212
- Under this box, there should be a checkbox labeled “Use this for Recipient URL and Destination URL”. Check the box if it is not already selected.
1313
- For “Audience URI (SP Entity ID)”, set the value to `<URL>`/.auth/saml/metadata
14-
- For "Name ID format", choose "EmailAddress"
14+
- For "Name ID format", choose "Persistent"
15+
- For "Application username", choose "Custom" and insert `user.getInternalProperty("id")`.
1516
- In the section titled “Attribute Statements (optional)”:
1617
- Set the following Name and Values, leaving the Name format to “Unspecified”
17-
- Email: user.email (This one is required)
18-
- Login: user.login (This one is optional)
19-
- displayName: user.firstName (This one is optional)
18+
- `email`: `user.email`
19+
- `login`: `user.login`
20+
- `displayName`: `user.firstName` or an alternative field
2021
6. Click Next.
2122
7. Now you should be on the “Feedback” step. Select the radio button for “I’m an Okta customer adding an internal app”, and provide feedback if you wish. Click "Finish".
2223
8. You should now be on the Application page for Sourcegraph, where you can view the settings and configurations you have just set. You will want to grant users or groups sign-in access before moving on.
@@ -52,4 +53,4 @@
5253
}
5354
```
5455

55-
> NOTE: Optional, but recommended: [add automatic provisioning of users with SCIM](/admin/scim).
56+
<Callout type="note">Optional, but recommended: [add automatic provisioning of users with SCIM](/admin/scim).</Callout>

docs/admin/code_hosts/gitlab.mdx

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -98,38 +98,6 @@ Then, [add or edit a GitLab connection](#repository-syncing) and include the `au
9898
In this case, a user's OAuth token will be used to get a list of repositories that the user can access.
9999
[Repository-centric permissions syncing](/admin/permissions/syncing) will be disabled.
100100

101-
### Administrator (sudo-level) access token
102-
103-
This method requires administrator access to GitLab so that Sourcegraph can access the [admin GitLab Users API endpoint](https://docs.gitlab.com/ee/api/users.html#for-admins). For each GitLab user, this endpoint provides the user ID that comes from the authentication provider, so Sourcegraph can associate a user in its system to a user in GitLab.
104-
105-
Prerequisite: Add the [SAML](/admin/auth/#saml) or [OpenID Connect](/admin/auth/#openid-connect)
106-
authentication provider you use to sign into GitLab.
107-
108-
Then, [add or edit a GitLab connection](#repository-syncing) using an administrator (sudo-level) personal access token, and include the `authorization` field:
109-
110-
```json
111-
{
112-
"url": "https://gitlab.com",
113-
"token": "$PERSONAL_ACCESS_TOKEN",
114-
// ...
115-
"authorization": {
116-
"identityProvider": {
117-
"type": "external",
118-
"authProviderID": "$AUTH_PROVIDER_ID",
119-
"authProviderType": "$AUTH_PROVIDER_TYPE",
120-
"gitlabProvider": "$AUTH_PROVIDER_GITLAB_ID"
121-
}
122-
}
123-
}
124-
```
125-
126-
`$AUTH_PROVIDER_ID` and `$AUTH_PROVIDER_TYPE` identify the authentication provider to use and should
127-
match the fields specified in the authentication provider config
128-
(`auth.providers`). The authProviderID can be found in the `configID` field of the auth provider config.
129-
130-
`$AUTH_PROVIDER_GITLAB_ID` should match the `identities.provider` returned by
131-
[the admin GitLab Users API endpoint](https://docs.gitlab.com/ee/api/users.html#for-admins).
132-
133101
### Username
134102

135103
Prerequisite: Ensure that `http-header` is the *only* authentication provider type configured for
@@ -296,7 +264,7 @@ See [Internal rate limits](/admin/code_hosts/rate_limits#internal-rate-limits).
296264
// It is important that the Sourcegraph repository name generated with this pattern be unique to this code host. If different code hosts generate repository names that collide, Sourcegraph's behavior is undefined.
297265
"repositoryPathPattern": "{host}/{pathWithNamespace}",
298266

299-
// A GitLab access token with "api" scope. Can be a personal access token (PAT) or an OAuth token. If you are enabling permissions with identity provider type "external", this token should also have "sudo" scope.
267+
// A GitLab access token with "api" scope. Can be a personal access token (PAT) or an OAuth token. If you are enabling permissions with identity provider type "username", this token should also have "sudo" scope.
300268
"token": null,
301269

302270
// The OAuth token expiry (Unix timestamp in seconds)

docs/admin/config/authorization_and_authentication.mdx

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -68,48 +68,13 @@ Once authentication with GitHub via OAuth is configured, follow [these steps to
6868

6969
### GitLab Enterprise or GitLab Cloud authentication and authorization
7070

71-
We support both authentication and permissions syncing (through OAuth) for GitLab. If you use GitLab as your code host, you have two available authentication flows:
72-
73-
#### Option 1
71+
We support both authentication and permissions syncing (through OAuth) for GitLab.
7472

7573
1. Use SAML (or another auth mechanism) to log in to GitLab
7674
2. Use GitLab OAuth to log in to Sourcegraph
7775

7876
In this way, access to Sourcegraph will still be managed by your identity provider, using the code host as a middle step. This option is the simplest to configure. To do so, [set up GitLab as an authentication option](/admin/auth/#gitlab), and then [enable permissions syncing](/admin/code_hosts/gitlab#oauth-application).
7977

80-
#### Option 2
81-
82-
Alternatively, you can configure SAML authentication in Sourcegraph, and use GitLab permissions syncing in the background to control access permissions. To implement this method, you will need to make sure that GitLab is able to return a value in `identities.provider` for the `GET /users` endpoint ([GitLab documentation](https://docs.gitlab.com/ee/api/users.html#for-admins)) that your identity provider is able to pass as the `nameID` in the SAML response. If that isn’t possible, you will need to use the first option.
83-
84-
To configure SAML auth with GitLab permissions, you will need to first [configure permissions from GitLab](/admin/code_hosts/gitlab#administrator-sudo-level-access-token). Then, [configure SAML authentication](/admin/auth/saml/). The `nameID` passed by the identity provider will need to match the value of `identities.provider`.
85-
86-
For example, if the GitLab API returns:
87-
88-
```json
89-
{
90-
"identities": [{ "provider": "saml", "extern_uid": "[email protected]" }]
91-
}
92-
```
93-
94-
Then you will need to configure permission in Sourcegraph as:
95-
96-
```json
97-
{
98-
"url": "https://gitlab.com",
99-
"token": "$PERSONAL_ACCESS_TOKEN",
100-
"authorization": {
101-
"identityProvider": {
102-
"type": "external",
103-
"authProviderID": "$AUTH_PROVIDER_ID",
104-
"authProviderType": "$AUTH_PROVIDER_TYPE",
105-
"gitlabProvider": "saml"
106-
}
107-
}
108-
}
109-
```
110-
111-
And configure the identity provider to pass the email address as the `nameID`.
112-
11378
### Bitbucket Server / Bitbucket Data Center authorization
11479

11580
We do not currently support OAuth for Bitbucket Server or Bitbucket Data Center. You will need to combine permissions syncing from Bitbucket Server / Bitbucket Data Center with another authentication mechanism (SAML, built-in auth, HTTP authentication proxies). Bitbucket Server and Bitbucket Data Center only pass usernames to Sourcegraph, so you’ll need to make sure that those usernames are matched by whatever mechanism you choose to use for access.

docs/admin/config/email.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Sourcegraph uses an SMTP server of your choosing to send emails for:
77
- Important updates to a user accounts (for example, creation of API keys)
88
- For [`builtin` authentication](/admin/auth/#builtin-password-authentication), password resets and email verification
99

10-
> NOTE: Sourcegraph Cloud customers can take advantage of mananged SMTP servers - [learn more](/cloud/#managed-smtp).
10+
<Callout type="note">Sourcegraph Cloud customers can take advantage of mananged SMTP servers - [learn more](/cloud/#managed-smtp).</Callout>
1111

1212
## User email verification
1313

@@ -82,8 +82,8 @@ Make sure that `[email protected]` in both places of the configuration matches th
8282

8383
Other providers such as Mailchimp and Sendgrid may also be used with Sourcegraph. Any valid SMTP server account should do. For those two providers in specific, you may follow their documentation:
8484

85-
* https://mailchimp.com/developer/transactional/docs/smtp-integration/
86-
* https://docs.sendgrid.com/for-developers/sending-email/getting-started-smtp
85+
- [https://mailchimp.com/developer/transactional/docs/smtp-integration/](https://mailchimp.com/developer/transactional/docs/smtp-integration/)
86+
- [https://docs.sendgrid.com/for-developers/sending-email/getting-started-smtp](https://docs.sendgrid.com/for-developers/sending-email/getting-started-smtp)
8787

8888
Once you have an SMTP account, simply navigate to your site configuration (e.g. `https://sourcegraph.com/site-admin/configuration`) and fill in the configuration:
8989

docs/admin/config/webhooks/outgoing.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Outgoing webhooks
22

3+
<<<<<<< Updated upstream
34
<Callout type="note"> This feature is supported on Sourcegraph versions 5.0 or more.</Callout>
5+
=======
6+
<Callout type="note"> This feature is currently in beta and supported on Sourcegraph versions 5.0 or later.</Callout>
7+
>>>>>>> Stashed changes
48
59
Outgoing webhooks can be configured on a Sourcegraph instance in order to send Sourcegraph events to external tools and services. This allows for deeper integrations between Sourcegraph and other applications.
610

docs/admin/permissions/index.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ of `alice` are the following union set: [`horsegraph/global`, `horsegraph/hay-v1
124124
### Configuration
125125

126126
**Prerequisites:**
127+
127128
1. Sourcegraph version 5.0+
128129
1. Go to **Site Admin > Migrations** page. There is a migration called `Migrate data from user_permissions table to unified user_repo_permissions.`.
129130
Make sure that it finished migrating all the data (it reports as 100%). Contact support if the migration does not seem to complete for a long time (multiple days).
@@ -150,8 +151,8 @@ permission sync, it will replace the existing set of synced permissions for that
150151

151152
**Example**:
152153

153-
Let's follow the example from above, `alice` has existing synced permissions to repositories `horsegraph/global` and `horsegraph/hay-v1`
154-
and explicit permissions to `horsegraph/hay-dev`, meaning a unioned set of effective permissions of [`horsegraph/global`, `horsegraph-hay-v1`, `horsegraph/hay-dev`].
154+
Let's follow the example from above. `alice` has existing synced permissions for the repositories `horsegraph/global` and `horsegraph/hay-v1`
155+
and explicit permissions set for `horsegraph/hay-dev`, meaning a unioned set of effective permissions of [`horsegraph/global`, `horsegraph/hay-v1`, `horsegraph/hay-dev`].
155156

156157
An update comes in from permission sync, now returning `alice` permissions as [`horsegraph/global`, `horsegraph/hay-v2`]. Notice
157158
the removal of `horsegraph-v1` from the set.

docs/admin/permissions/syncing.mdx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ permissions. Both are on by default, resulting in double polling:
1010
Sourcegraph collects this information and stores it in internal database.
1111

1212
To see which code hosts support permission syncing, please refer to [Supported code hosts table](/admin/#supported-code-hosts).
13+
1314
## How it works
1415

1516
### Periodic sync
@@ -27,6 +28,7 @@ Besides periodic schedule of jobs, we also have a way to request permission sync
2728
or repository on-demand. This is useful for example when a new user is added to Sourcegraph.
2829

2930
To do that, the following GraphQL request needs to be made:
31+
3032
```graphql
3133
mutation {
3234
scheduleUserPermissionsSync(user: "user") {
@@ -36,6 +38,7 @@ mutation {
3638
```
3739

3840
Or in the case of adding a repository, the following request is made:
41+
3942
```graphql
4043
mutation {
4144
scheduleRepositoryPermissionsSync(repository: "repository") {
@@ -45,6 +48,7 @@ mutation {
4548
```
4649

4750
**Example**:
51+
4852
- User `bob` is added to Sourcegraph.
4953
- `bob` has access to repositories `horsegraph/global` and `horsegraph/bob` on the code host
5054
- an on-demand request is made to sync repository permissions of `bob`, this job is added to the queue with high priority, so it will be processed
@@ -69,6 +73,7 @@ processed. To avoid overloading the code host a sync job [might not be processed
6973
and depending on the code host, might be heavily rate limited.
7074

7175
Priority queue is needed to process the sync jobs in the order of most important first. E.g.:
76+
7277
- on-demand sync is high priority
7378
- sync of entities with no permissions is high priority
7479
- sync of oldest permissions is normal priority, since we already do have some permissions in the system
@@ -230,13 +235,14 @@ mentioned above. Even if we let permission sync consume all the rate limit and w
230235
is rarely the case. Depending on the code host, the rate limit might be much higher, but then we might be
231236
firing huge amounts of requests to the code host.
232237

233-
> IMPORTANT: For permission syncing to be quicker, the code host needs to be able to handle big amounts of requests per hour.
238+
<Callout type="warning">IMPORTANT: For permission syncing to be quicker, the code host needs to be able to handle big amounts of requests per hour.</Callout>
234239

235-
> IMPORTANT: Depending on the customer scale, the amount of users, repositories and the distribution of permissions accross them, the time it takes to fully sync will vary.
240+
<Callout type="warning">IMPORTANT: Depending on the customer scale, the amount of users, repositories and the distribution of permissions accross them, the time it takes to fully sync will vary.</Callout>
236241

237-
> IMPORTANT: We recommend **configuring webhooks for permissions on GitHub** which makes lag time much smaller.
242+
<Callout type="warning">IMPORTANT: We recommend **configuring webhooks for permissions on GitHub** which makes lag time much smaller.</Callout>
238243

239244
## Configuration
245+
240246
There are variety of options in the site configuration to tune how the permissions sync requests are
241247
scheduled. Default values are shown below:
242248

@@ -268,7 +274,9 @@ Internal rate limiter settings are described on each code host configuration pag
268274
### Recommendations
269275

270276
#### Less users than repositories
277+
271278
If there are a lot less users, than repositories, it is better to rely on user-centric perms sync instead of repo-centric sync. In that case, we recommend:
279+
272280
```json
273281
{
274282
// ...
@@ -288,6 +296,7 @@ a minute. `5000/(4 * 60) = 20.8`, so the scheduler needs to schedule 21 users on
288296

289297
The rate limit for the code host would need to be changed to support the load. In that case the recommendation
290298
is to set it to 2x of the amount of [requests expected from permission syncing](#request-count).
299+
291300
#### More users than repositories
292301

293302
If the situation is reversed, it is recommended to do the opposite than above. Prefer repo-centric

0 commit comments

Comments
 (0)