@sensinum/strapi-plugin-multi-domain 5.1.4 → 5.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -35
- package/dist/server/index.js +4 -3
- package/dist/server/index.mjs +5516 -5322
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ This plugin brings multi-domain support to your Strapi application. It allows yo
|
|
|
22
22
|
> ✅ **GET THE LICENSE**: To obtain the license we encourage you to [**visit the plugin commercial website**](http://sensinum.com/strapi-multi-domain-plugin), select the appropriate plan, and reach out to your preferred reseller or directly contact the plugin authors via [**this form**](http://sensinum.com/contact)
|
|
23
23
|
|
|
24
24
|
> ⚠️ **This plugin is licensed by VirtusLab Ltd. under the [End User License Agreement (EULA)](https://sensinum.com/eula-strapi-multi-domain-plugin).**
|
|
25
|
-
Unauthorized use, including usage without a valid license key or modification of the code in a way that breaches the integrity of the software, is strictly prohibited and will be treated as a violation of the [EULA](https://sensinum.com/eula-strapi-multi-domain-plugin), with all associated legal consequences.
|
|
25
|
+
> Unauthorized use, including usage without a valid license key or modification of the code in a way that breaches the integrity of the software, is strictly prohibited and will be treated as a violation of the [EULA](https://sensinum.com/eula-strapi-multi-domain-plugin), with all associated legal consequences.
|
|
26
26
|
|
|
27
27
|
### Table of Contents
|
|
28
28
|
|
|
@@ -33,23 +33,24 @@ Unauthorized use, including usage without a valid license key or modification of
|
|
|
33
33
|
5. [🔧 Configuration](#-configuration)
|
|
34
34
|
6. [🧪 Testing](#-testing)
|
|
35
35
|
7. [👨💻 For Developers: Advanced Customization](#-for-developers-advanced-customization-via-sharedpluginidsts)
|
|
36
|
-
8. [
|
|
36
|
+
8. [🔌 Supported Third-Party Plugins](#-supported-third-party-plugins)
|
|
37
|
+
9. [📝 License](#-license)
|
|
37
38
|
|
|
38
39
|
## ✨ Features
|
|
39
40
|
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
41
|
+
- **Domain-based Data Isolation**: Automatically scopes content types to the current user's domain.
|
|
42
|
+
- **Media Library Segregation**: Each domain has its own isolated section within the media library.
|
|
43
|
+
- **User-Domain Association**: Users can be associated with one or more domains through Strapi roles.
|
|
44
|
+
- **Domain Selector**: A convenient domain selector is added to the admin UI for users who belong to multiple domains.
|
|
45
|
+
- **Super Admin Access**: Super admins have the ability to view data across all domains.
|
|
46
|
+
- **Configurable**: Easily configure which content types should be domain-aware.
|
|
46
47
|
|
|
47
48
|
## 🎨 Admin Panel Features
|
|
48
49
|
|
|
49
|
-
-
|
|
50
|
-
-
|
|
51
|
-
-
|
|
52
|
-
-
|
|
50
|
+
- **Domain Management UI**: A dedicated settings page in the admin panel (`Settings > Multi-Domain Settings`) allows administrators to create, view, update, and delete domains.
|
|
51
|
+
- **Domain Selector**: Users belonging to multiple domains will see a "Select domain" option in the user menu (top right). This opens a modal allowing them to easily switch between their assigned domains, reloading the app context for the selected domain.
|
|
52
|
+
- **"Unique by Domain" Custom Field**: The plugin registers a new custom field type named "Unique by domain". When applied to a text field on a content type, it ensures that the value of that field is unique among all entries of that type within the _same domain_.
|
|
53
|
+
- **Content Manager Integration**: To prevent content from being created without a domain, the "Create new entry" button in the Content Manager is hidden when the "Super Admin" domain is selected.
|
|
53
54
|
|
|
54
55
|
## ⚙️ How it works
|
|
55
56
|
|
|
@@ -70,6 +71,7 @@ When using the **Users & Permissions plugin** with multi-domain functionality, t
|
|
|
70
71
|
2. **Use API tokens assigned to domains**: Ensure all requests include an API token that is properly assigned to a specific domain. This allows the plugin to identify the correct domain context for the request.
|
|
71
72
|
|
|
72
73
|
#### Example:
|
|
74
|
+
|
|
73
75
|
```javascript
|
|
74
76
|
// In your route configuration
|
|
75
77
|
module.exports = {
|
|
@@ -114,9 +116,7 @@ module.exports = {
|
|
|
114
116
|
* By default, all content-types are scoped except for some internal Strapi models.
|
|
115
117
|
* @returns {Set<string>}
|
|
116
118
|
*/
|
|
117
|
-
getOmitContentTypes: () => new Set([
|
|
118
|
-
'api::my-global-content-type.my-global-content-type',
|
|
119
|
-
]),
|
|
119
|
+
getOmitContentTypes: () => new Set(['api::my-global-content-type.my-global-content-type']),
|
|
120
120
|
/**
|
|
121
121
|
* A list of content-api endpoints to exclude from domain logic.
|
|
122
122
|
* e.g., ['/api/my-public-endpoint']
|
|
@@ -150,14 +150,14 @@ module.exports = {
|
|
|
150
150
|
|
|
151
151
|
### Configuration Options
|
|
152
152
|
|
|
153
|
-
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
-
|
|
157
|
-
-
|
|
158
|
-
-
|
|
159
|
-
|
|
160
|
-
|
|
153
|
+
- `defaultDomain` (object): Configures the domain that is automatically created for super admins.
|
|
154
|
+
- `name` (string): The display name for the default domain.
|
|
155
|
+
- `customFields` (object): A JSON object for any custom data you want to associate with the domain.
|
|
156
|
+
- `getOmitContentTypes` (function): Returns a `Set` of content-type UIDs that should be excluded from multi-domain. Use this for global, non-domain-specific content.
|
|
157
|
+
- `getExcludedContentAPIEndpoints` (function): Returns an array of URL paths for Content API endpoints that should be publicly accessible and not scoped by domain.
|
|
158
|
+
- `getExtraProxyDecorators` (function): An advanced feature that allows you to add custom logic to the database query proxy. This is useful for implementing complex, domain-specific business rules. It should return an array of objects, each with a `condition` and a `handler` function.
|
|
159
|
+
- `condition` (function): Takes a `modelName` and returns `true` if the handler should be applied.
|
|
160
|
+
- `handler` (function): A function that wraps the original database method, allowing you to modify its behavior. It receives the `target` repository, the original `targetElement` method, the Koa `ctx`, the method `prop` name, and the `modelName`.
|
|
161
161
|
|
|
162
162
|
Here's an example of how you might use `getExtraProxyDecorators` to add an additional filter to a specific content type:
|
|
163
163
|
|
|
@@ -182,9 +182,7 @@ module.exports = {
|
|
|
182
182
|
* By default, all content-types are scoped except for some internal Strapi models.
|
|
183
183
|
* @returns {Set<string>}
|
|
184
184
|
*/
|
|
185
|
-
getOmitContentTypes: () => new Set([
|
|
186
|
-
'api::my-global-content-type.my-global-content-type',
|
|
187
|
-
]),
|
|
185
|
+
getOmitContentTypes: () => new Set(['api::my-global-content-type.my-global-content-type']),
|
|
188
186
|
/**
|
|
189
187
|
* A list of content-api endpoints to exclude from domain logic.
|
|
190
188
|
* e.g., ['/api/my-public-endpoint']
|
|
@@ -220,7 +218,6 @@ module.exports = {
|
|
|
220
218
|
|
|
221
219
|
To run the tests for this plugin, navigate to the plugin's directory and run the following command:
|
|
222
220
|
|
|
223
|
-
|
|
224
221
|
This will execute the Jest test suite. To run tests in watch mode, you can use `yarn test:watch`.
|
|
225
222
|
|
|
226
223
|
## 👨💻 For Developers: Advanced Customization via `shared/pluginIds.ts`
|
|
@@ -235,16 +232,48 @@ By changing the values in this file, you can fundamentally alter the plugin's id
|
|
|
235
232
|
|
|
236
233
|
Here's a breakdown of the constants and what you can control by changing them:
|
|
237
234
|
|
|
238
|
-
-
|
|
235
|
+
- `pluginId`: The official ID of the plugin (`multi-domain`). Changing this will alter the plugin's root path in Strapi, including settings URLs and permission domains.
|
|
236
|
+
|
|
237
|
+
> **Note:** This value is derived from the `strapi.name` property in `package.json` and should always be kept in sync with it.
|
|
238
|
+
|
|
239
|
+
- `modelId`: The singular ID for the domain content type (default: `'domain'`). Changing this renames the content type itself, which affects the database table, API endpoints, and the name of the relationship field added to other content types.
|
|
240
|
+
- `modelServiceId`: The identifier for the domain service (default: `'domain'`). This should typically be kept in sync with `modelId`.
|
|
241
|
+
- `userField`: The property name on the `user` object where associated domain information is stored (default: `'domain'`).
|
|
242
|
+
- `modelRoute`: The base route for the domain management API (default: `'domains'`). This is derived from `modelId`, so changing `modelId` will automatically update this.
|
|
243
|
+
- `COOKIE_NAME`: The name of the cookie used to store the user's currently selected domain (default: `'domain'`). You might change this to avoid naming conflicts with other cookies in your application.
|
|
244
|
+
|
|
245
|
+
## 🔌 Supported Third-Party Plugins
|
|
246
|
+
|
|
247
|
+
This plugin provides domain-scoped data isolation for the following third-party plugins:
|
|
248
|
+
|
|
249
|
+
- [strapi-plugin-navigation](https://github.com/VirtusLab-Open-Source/strapi-plugin-navigation)
|
|
250
|
+
- [strapi-plugin-comments](https://github.com/VirtusLab-Open-Source/strapi-plugin-comments)
|
|
251
|
+
- [strapi-plugin-reactions](https://github.com/VirtusLab-Open-Source/strapi-plugin-reactions)
|
|
252
|
+
|
|
253
|
+
### strapi-plugin-navigation
|
|
254
|
+
|
|
255
|
+
Navigation items and navigations are automatically scoped to the current domain.
|
|
256
|
+
|
|
257
|
+
### strapi-plugin-comments
|
|
239
258
|
|
|
240
|
-
|
|
259
|
+
Comments and comment reports are automatically scoped to the current domain. Since the `Authorization` header is reserved for the domain API token, author identification for comments is handled via the `X-Author-Authorization` header:
|
|
260
|
+
|
|
261
|
+
```
|
|
262
|
+
X-Author-Authorization: Bearer <users-permissions-jwt>
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
This header is processed on comment endpoints that require author context: creating, updating, and deleting comments. If the token is valid, the resolved Strapi user is set as the comment author. Without this header, the comment must include an `author` object in the request body with `id`, `name`, and `email` fields.
|
|
266
|
+
|
|
267
|
+
### strapi-plugin-reactions
|
|
268
|
+
|
|
269
|
+
Reactions and reaction types are automatically scoped to the current domain. Since the `Authorization` header is reserved for the domain API token, author identification for reactions is handled via the `X-Author-Authorization` header:
|
|
270
|
+
|
|
271
|
+
```
|
|
272
|
+
X-Author-Authorization: Bearer <users-permissions-jwt>
|
|
273
|
+
```
|
|
241
274
|
|
|
242
|
-
|
|
243
|
-
- `modelServiceId`: The identifier for the domain service (default: `'domain'`). This should typically be kept in sync with `modelId`.
|
|
244
|
-
- `userField`: The property name on the `user` object where associated domain information is stored (default: `'domain'`).
|
|
245
|
-
- `modelRoute`: The base route for the domain management API (default: `'domains'`). This is derived from `modelId`, so changing `modelId` will automatically update this.
|
|
246
|
-
- `COOKIE_NAME`: The name of the cookie used to store the user's currently selected domain (default: `'domain'`). You might change this to avoid naming conflicts with other cookies in your application.
|
|
275
|
+
This header is processed on reaction endpoints: listing, creating, deleting, and toggling reactions. If the token is valid, the resolved Strapi user is set as the reaction author. The reactions plugin also supports its own `X-Reactions-Author` header for custom (non-Strapi) users. When `X-Reactions-Author` is present, `X-Author-Authorization` is ignored — custom author identification takes precedence.
|
|
247
276
|
|
|
248
277
|
## 📝 License
|
|
249
278
|
|
|
250
|
-
All rights reserved. Copyright (c) [VirtusLab Ltd](https://virtuslab.com/).
|
|
279
|
+
All rights reserved. Copyright (c) [VirtusLab Ltd](https://virtuslab.com/).
|