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