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
Copy file name to clipboardExpand all lines: docs/admin/repo/perforce.mdx
+34-18Lines changed: 34 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -154,26 +154,42 @@ To enable file-level permissions:
154
154
155
155
Permissions will be synced in the background based on your [Perforce protects file](https://www.perforce.com/manuals/cmdref/Content/CmdRef/p4_protect.html).
156
156
157
-
#### Handling host rules in the protects file
157
+
#### Handling IP-based rules
158
158
159
-
By default, Sourcegraph applies all rules in the protects table regardless of the host rule (treating all host rules as the wildcard `*`). If your setup relies heavily on host rules, this could lead to unintended permissions for users.
159
+
Perforce's `protects` table allows administrators to define fine-grained access controls based on user identities and host IP addresses. By default, Sourcegraph applies all rules from the `protects` table without considering host-specific restrictions, effectively treating all host rules as the wildcard `*`. This behavior can lead to users having unintended access to repositories or files that should be restricted based on their IP addresses.
160
160
161
-
You have two options if the default behavior is not suitable:
161
+
If your Perforce environment relies heavily on host-based permissions, it's crucial to configure Sourcegraph appropriately to respect these restrictions. This documentation provides detailed instructions on how to enforce or ignore host rules in Sourcegraph when integrating with Perforce.
162
162
163
-
1. Enforce host rules
164
-
1. Ignore rules that have a host value other than `*`
163
+
##### Default Behavior
164
+
165
+
By default, Sourcegraph:
166
+
167
+
-**Applies all rules** in the Perforce `protects` table.
168
+
-**Ignores host-specific restrictions**, treating all host fields as `*`.
169
+
170
+
**Implication**: Users may gain access to resources that should be restricted based on their IP addresses.
171
+
172
+
##### Configuration Options
173
+
174
+
To ensure Sourcegraph handles host rules according to your requirements, you have two additional options:
175
+
176
+
1.**Enforce Host Rules**: Configure Sourcegraph to respect and enforce IP-based restrictions defined in the `protects` table.
177
+
2.**Ignore Host-Specific Rules**: Configure Sourcegraph to disregard any rules with a host value other than `*`.
165
178
166
179
##### Enforcing host rules
167
180
168
-
To enforce host-specific rules, modify your [site configuration](https://sourcegraph.com/github.com/sourcegraph/sourcegraph@2a716bd/-/blob/schema/site.schema.json?L227-249) as follows:
181
+
If you want Sourcegraph to enforce host-specific permissions, you need to enable IP restriction enforcement in your [site configuration](https://sourcegraph.com/docs/admin/config/site_config):
When `enforceIPRestrictions` is set to `true`, Sourcegraph will use the user's IP address to apply Perforce permissions at the user level. It uses the final `X-Forwarded-For` header in the request to identify the user's IP. Note that this header can be easily spoofed, so ensure your load balancer or proxy handles `X-Forwarded-For` headers securely.
179
195
@@ -182,12 +198,12 @@ When `enforceIPRestrictions` is set to `true`, Sourcegraph will use the user's I
182
198
To ignore rules that have a host value other than `*`, set `ignoreRulesWithHost` to `true` in your **code host configuration**:
183
199
184
200
```json
185
-
{
186
-
"authorization": {
187
-
"subRepoPermissions": true,
188
-
"ignoreRulesWithHost": true
189
-
}
190
-
}
201
+
{
202
+
"authorization": {
203
+
"subRepoPermissions": true,
204
+
"ignoreRulesWithHost": true
205
+
}
206
+
}
191
207
```
192
208
193
209
With this setting, Sourcegraph will ignore any rules with a host other than `*`, treating them as if they do not exist.
0 commit comments