@authhero/multi-tenancy 13.1.3 → 13.2.0
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 +35 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,6 +10,7 @@ Multi-tenancy support for AuthHero with organization-based access control, per-t
|
|
|
10
10
|
- 🌐 **Subdomain Routing** - Automatic subdomain-to-tenant resolution
|
|
11
11
|
- 🔄 **Tenant Lifecycle** - Automated provisioning and deprovisioning
|
|
12
12
|
- 🪝 **Hooks Integration** - Seamless integration with AuthHero hooks system
|
|
13
|
+
- 📡 **Resource Server Sync** - Automatically sync resource servers from main tenant to all child tenants
|
|
13
14
|
|
|
14
15
|
## Installation
|
|
15
16
|
|
|
@@ -82,6 +83,40 @@ const token = await getAccessTokenSilently({
|
|
|
82
83
|
});
|
|
83
84
|
```
|
|
84
85
|
|
|
86
|
+
## Resource Server Synchronization
|
|
87
|
+
|
|
88
|
+
Automatically sync resource servers (APIs) from the main tenant to all child tenants. When you create, update, or delete a resource server on the main tenant, it's automatically propagated to all other tenants.
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
import { createResourceServerSyncHooks } from "@authhero/multi-tenancy";
|
|
92
|
+
|
|
93
|
+
const resourceServerHooks = createResourceServerSyncHooks({
|
|
94
|
+
mainTenantId: "main",
|
|
95
|
+
getChildTenantIds: async () => {
|
|
96
|
+
// Return all tenant IDs except the main tenant
|
|
97
|
+
const { tenants } = await adapters.tenants.list();
|
|
98
|
+
return tenants.filter((t) => t.id !== "main").map((t) => t.id);
|
|
99
|
+
},
|
|
100
|
+
getAdapters: async (tenantId) => {
|
|
101
|
+
// Return adapters for the target tenant
|
|
102
|
+
return createAdaptersForTenant(tenantId);
|
|
103
|
+
},
|
|
104
|
+
// Optional: filter which resource servers to sync
|
|
105
|
+
shouldSync: (resourceServer) => {
|
|
106
|
+
// Only sync resource servers that start with "api:"
|
|
107
|
+
return resourceServer.identifier.startsWith("api:");
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// Use with AuthHero config
|
|
112
|
+
const config: AuthHeroConfig = {
|
|
113
|
+
dataAdapter,
|
|
114
|
+
entityHooks: {
|
|
115
|
+
resourceServers: resourceServerHooks,
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
```
|
|
119
|
+
|
|
85
120
|
## License
|
|
86
121
|
|
|
87
122
|
MIT
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"type": "git",
|
|
12
12
|
"url": "https://github.com/markusahlstrand/authhero"
|
|
13
13
|
},
|
|
14
|
-
"version": "13.
|
|
14
|
+
"version": "13.2.0",
|
|
15
15
|
"description": "Multi-tenancy support for AuthHero with organization-based access control and per-tenant database isolation",
|
|
16
16
|
"files": [
|
|
17
17
|
"dist"
|