Skip to content

Commit 88631eb

Browse files
committed
Slight rewording
1 parent 688d8ff commit 88631eb

File tree

1 file changed

+34
-18
lines changed

1 file changed

+34
-18
lines changed

docs/admin/repo/perforce.mdx

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -154,26 +154,42 @@ To enable file-level permissions:
154154

155155
Permissions will be synced in the background based on your [Perforce protects file](https://www.perforce.com/manuals/cmdref/Content/CmdRef/p4_protect.html).
156156

157-
#### Handling host rules in the protects file
157+
#### Handling IP-based rules
158158

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.
160160

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.
162162

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 `*`.
165178

166179
##### Enforcing host rules
167180

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):
169182

170-
```json
171-
{
172-
"experimentalFeatures": {
173-
"subRepoPermissions": { "enabled": true, "enforceIPRestrictions": true }
174-
}
183+
```json
184+
{
185+
"experimentalFeatures": {
186+
"subRepoPermissions": {
187+
"enabled": true,
188+
"enforceIPRestrictions": true
175189
}
176-
```
190+
}
191+
}
192+
```
177193

178194
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.
179195

@@ -182,12 +198,12 @@ When `enforceIPRestrictions` is set to `true`, Sourcegraph will use the user's I
182198
To ignore rules that have a host value other than `*`, set `ignoreRulesWithHost` to `true` in your **code host configuration**:
183199

184200
```json
185-
{
186-
"authorization": {
187-
"subRepoPermissions": true,
188-
"ignoreRulesWithHost": true
189-
}
190-
}
201+
{
202+
"authorization": {
203+
"subRepoPermissions": true,
204+
"ignoreRulesWithHost": true
205+
}
206+
}
191207
```
192208

193209
With this setting, Sourcegraph will ignore any rules with a host other than `*`, treating them as if they do not exist.

0 commit comments

Comments
 (0)