Domain Access Entity

Extends Domain Access functionality to any fieldable entity type, allowing domain-based access control beyond just nodes.

domain_entity
1,755 sites
24
drupal.org

Overview

Domain Access Entity provides a powerful solution for adding Domain Access control to any fieldable entity type in Drupal. While the core Domain Access module only handles node access, this module extends that capability to all entity types including taxonomy terms, paragraphs, blocks, media, and custom entities.

The module adds a domain_access field to selected entity types, enabling content to be restricted to specific domains. Entities without domain assignments remain accessible across all domains. It also provides a domain_source field for URL rewriting, ensuring entity URLs point to their canonical domain.

Site administrators can configure domain access on a per-entity-type and per-bundle basis, choosing between automatic domain assignment (hidden from users) or user-selectable domain affiliation. The module integrates with Views and provides granular permissions for creating, editing, and deleting content on assigned domains.

Features

  • Enable Domain Access control on any fieldable entity type (taxonomy terms, paragraphs, blocks, media, etc.)
  • Configurable domain access per entity bundle with automatic or user-selectable domain assignment
  • Domain Source field for canonical URL rewriting across domains
  • Query access conditions that automatically filter entities by current domain
  • Dynamic permissions generation for create/update/delete operations per entity bundle
  • Batch update support for assigning existing entities to default domains
  • Integration with Domain Access module's permission system
  • Route exclusion settings for domain source URL rewrites
  • Submodule for domain-based menu link access control

Use Cases

Multi-brand taxonomy management

A company with multiple brands sharing a codebase can create taxonomy terms specific to each brand's domain. Product categories, tags, and other taxonomies can be domain-specific while sharing the same vocabulary structure.

Domain-specific media library

Media entities can be assigned to specific domains, allowing different sites to maintain separate image libraries while using a shared Drupal installation.

Cross-domain content with canonical URLs

Content can be accessible on multiple domains while maintaining a canonical URL on its primary domain using the domain source feature. This helps with SEO by avoiding duplicate content issues.

Multi-tenant paragraphs

Paragraph types can be domain-restricted, allowing different sites to have access to different component libraries while sharing the same paragraph configuration.

Domain-specific navigation

Using the domain_menu_access submodule, menu items can be shown or hidden based on the current domain, allowing each site to have its own navigation structure.

Tips

  • Use the bypass access conditions setting temporarily for troubleshooting access issues without disabling the module
  • Assign users to domains via the Affiliate editor options in user profiles to allow cross-domain content management
  • When migrating entities, ensure domain assignments are included or entities will become inaccessible
  • The domain source field determines the canonical URL domain, while domain_access controls which domains can access the entity
  • For Views displaying cross-domain content, expose the domain field filter to allow editors to switch between domains

Technical Details

Admin Pages 2
Entities /admin/config/domain/entities

Main configuration page for enabling domain access on entity types. Lists all available fieldable entity types and allows enabling/disabling domain access control for each. Provides a quick toggle for bypassing access conditions for troubleshooting.

Activate domain access on [Entity Type] /admin/config/domain/entities/{entity_type_id}

Bundle-specific configuration page for an entity type. Configure domain access settings for each bundle including field behavior, default domain values, and domain source settings.

Permissions 5
Access and filter entities affiliate on user's assigned domains

Allow an editor of multiple domains to access entities on different domain. Users with this permission can view entities from all their assigned domains in administration pages.

Set domain access status for all entities

Allow editor to edit & set domain access for all entity types regardless of widget behavior settings.

[Entity Type]: [Bundle]: Create new content on assigned domains

Dynamic permission generated per entity bundle. Allows creating new entities of this type on domains the user is assigned to.

[Entity Type]: [Bundle]: Edit any content on assigned domains

Dynamic permission generated per entity bundle. Allows editing entities of this type on domains the user is assigned to.

[Entity Type]: [Bundle]: Delete any content on assigned domains

Dynamic permission generated per entity bundle. Allows deleting entities of this type on domains the user is assigned to.

Hooks 2
hook_domain_entity_source_alter

Allows modules to alter the domain source for entity URL rewriting.

hook_domain_entity_source_path_alter

Allows modules to add domain source handling to non-entity paths.

Troubleshooting 4
Entities not appearing after enabling domain access

Entities created before enabling domain access have no domain assignment and may become inaccessible. Use the batch update feature when enabling domain access to assign existing entities to default domains.

Views not filtering by domain correctly

Disable SQL rewriting in the View's advanced settings (Query Settings), or manually add a filter on the domain_access field to control which domains' entities appear.

Access denied errors in administration

Ensure users have the 'access entities affiliate on assigned domains' permission and are assigned to appropriate domains in their user profile's Affiliate editor options.

URL rewriting not working for entity links

Verify the domain_source field is enabled for the entity bundle and check that the route is not in the excluded routes list in the bundle configuration.

Security Notes 3
  • This module restricts access to 'administer domains' permission holders only
  • Dynamic permissions are generated per entity bundle - review carefully when adding new entity types
  • The bypass access conditions setting should only be used temporarily for debugging, not in production