1# Extranet
2
3[���� Français](README.md) | ���� English | [���� Deutsch](README_DE.md) | [���� Español](README_ES.md)
4
5DokuWiki plugin to restrict the display of pages, media files and some actions when the request comes from the extranet.
6
7The plugin can:
8- detect the extranet from a configurable `$_SERVER` value;
9- apply a default policy of `allow`, `block`, `force_allow` or `force_block`;
10- filter pages and media files by exact ID, namespace, wildcard or regex;
11- replace restricted page content with a configurable message;
12- replace restricted media files with a neutral image;
13- disable selected DokuWiki actions for extranet visitors;
14- handle the `~~NOEXTRANET~~` and `~~EXTRANET~~` macros;
15- integrate with ProseMirror so this state is preserved correctly in WYSIWYG mode.
16
17## Usage
18
19Two macros are available in pages:
20
21- `~~NOEXTRANET~~`: blocks the page from the extranet when the policy allows it;
22- `~~EXTRANET~~`: allows the page from the extranet when the policy allows it.
23
24The exact behavior depends on `default_policy`:
25
26- `allow`: everything is allowed except filtered pages or pages marked with `~~NOEXTRANET~~`
27- `block`: everything is blocked except filtered pages or pages marked with `~~EXTRANET~~`
28- `force_allow`: only filter rules apply, `~~NOEXTRANET~~` is ignored
29- `force_block`: only filter rules apply, `~~EXTRANET~~` is ignored
30
31## Configuration
32
33In the configuration manager:
34
35- `request_match_key`: `$_SERVER` key used to detect the extranet, for example `REMOTE_ADDR` or an `HTTP_*` header
36- `extranet_match_list`: comma-separated list of values treated as extranet
37- `extranet_match_regex`: regex used to identify the extranet from the configured value
38- `default_policy`: default access policy
39- `filter_list`: list of pages or media files affected by the policy
40- `filter_regex`: additional regex to target pages or media files
41- `hide_files`: whether restrictions also apply to media files
42- `disable_actions`: DokuWiki actions disabled for extranet visitors
43- `restricted_disable_actions`: additional actions disabled only when the current page is restricted
44- `preserve_first_title`: keeps the first heading when a page is hidden
45- `message_prefix`: content inserted before the restriction message
46- `message_suffix`: content inserted after the restriction message
47
48Compatibility:
49
50- `server_ip_key`
51- `extranet_ip_list`
52- `extranet_ip_regex`
53
54These legacy settings are still supported for compatibility, but the new names should be preferred.
55
56## Examples
57
58Detection by direct IP:
59
60- `request_match_key = REMOTE_ADDR`
61- `extranet_match_regex = /^10\.100\./`
62
63Detection by proxy header:
64
65- `request_match_key = HTTP_X_NETWORK_ZONE`
66- `extranet_match_list = extranet`
67
68Detection by upstream host name:
69
70- `request_match_key = HTTP_X_UPSTREAM_HOST`
71- `extranet_match_regex = /^frontend-ext-/`
72
73## What the helper provides
74
75Load the helper:
76
77```php
78$extranet = plugin_load('helper', 'extranet');
79```
80
81Main methods:
82
83- `getDefaultPolicy()`: returns the effective default policy
84- `getRequestMatchKey()`: returns the `$_SERVER` key used for detection
85- `getExtranetMatchList()`: returns the configured list of values
86- `getExtranetMatchRegex()`: returns the configured regex
87- `isExtranetRequest()`: tells whether the current request is treated as extranet
88- `isPageVisibleFromExtranet()`: tells whether a page is visible from the extranet
89- `isMediaVisibleFromExtranet()`: tells whether a media file is visible from the extranet
90- `isPageAllowed()`: tells whether a page is allowed in the current context
91- `isMediaAllowed()`: tells whether a media file is allowed in the current context
92- `parseRuleList()`: converts a list of rules into a usable array
93- `idMatchesRule()`: tests an ID against a rule
94
95## Cache and behavior
96
97The plugin splits the render cache to distinguish intranet and extranet visitors.
98
99When a page is restricted, its content is replaced with a configurable message. If `preserve_first_title` is enabled, the first heading is kept.
100
101If `hide_files` is enabled, restricted media files are replaced with a dedicated image.
102
103## Note
104
105The plugin relies on a request marker provided by the web infrastructure. It is suitable for intranet/extranet segmentation, but should not be treated as a replacement for ACLs or strong access control.
106