You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/modules/ROOT/pages/guides/how-to-multitenancy.adoc
+46-4Lines changed: 46 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,15 @@
5
5
:docs-dir: ..
6
6
7
7
This guide shows how to customize Spring Authorization Server to support multiple issuers per host in a multi-tenant hosting configuration.
8
+
The purpose of this guide is to demonstrate a general pattern for building multi-tenant capable components for Spring Authorization Server, which can also be applied to other components to suit your needs.
9
+
10
+
* xref:guides/how-to-multitenancy.adoc#multi-tenant-define-tenant-identifier[Define the tenant identifier]
11
+
* xref:guides/how-to-multitenancy.adoc#multi-tenant-create-component-registry[Create a component registry]
The xref:protocol-endpoints.adoc#oidc-provider-configuration-endpoint[OpenID Connect 1.0 Provider Configuration Endpoint] and xref:protocol-endpoints.adoc#oauth2-authorization-server-metadata-endpoint[OAuth2 Authorization Server Metadata Endpoint] allow for path components in the issuer identifier value, which effectively enables supporting multiple issuers per host.
10
19
@@ -27,6 +36,25 @@ NOTE: The base URL of the xref:protocol-endpoints.adoc[Protocol Endpoints] is th
27
36
28
37
Essentially, an issuer identifier with a path component represents the _"tenant identifier"_.
29
38
39
+
[[multi-tenant-create-component-registry]]
40
+
== Create a component registry
41
+
42
+
We start by building a simple registry for managing the concrete components for each tenant.
43
+
The registry contains the logic for retrieving a concrete implementation of a particular class using the issuer identifier value.
44
+
45
+
We will use the following class in each of the delegating implementations below:
TIP: This registry is designed to allow components to be easily registered at startup to support adding tenants statically, but also supports xref:guides/how-to-multitenancy.adoc#multi-tenant-add-tenants-dynamically[adding tenants dynamically] at runtime.
54
+
55
+
[[multi-tenant-create-components]]
56
+
== Create multi-tenant components
57
+
30
58
The components that require multi-tenant capability are:
@@ -39,7 +67,7 @@ For each of these components, an implementation of a composite can be provided t
39
67
Let's step through a scenario of how to customize Spring Authorization Server to support 2x tenants for each multi-tenant capable component.
40
68
41
69
[[multi-tenant-registered-client-repository]]
42
-
== Multi-tenant RegisteredClientRepository
70
+
=== Multi-tenant RegisteredClientRepository
43
71
44
72
The following example shows a sample implementation of a xref:core-model-components.adoc#registered-client-repository[`RegisteredClientRepository`] that is composed of 2x `JdbcRegisteredClientRepository` instances, where each instance is mapped to an issuer identifier:
<2> Use a separate H2 database instance using `issuer2-db` as the name.
76
104
77
105
[[multi-tenant-oauth2-authorization-service]]
78
-
== Multi-tenant OAuth2AuthorizationService
106
+
=== Multi-tenant OAuth2AuthorizationService
79
107
80
108
The following example shows a sample implementation of an xref:core-model-components.adoc#oauth2-authorization-service[`OAuth2AuthorizationService`] that is composed of 2x `JdbcOAuth2AuthorizationService` instances, where each instance is mapped to an issuer identifier:
<4> Obtain the `JdbcOAuth2AuthorizationService` that is mapped to the _"requested"_ issuer identifier indicated by `AuthorizationServerContext.getIssuer()`.
The following example shows a sample implementation of an xref:core-model-components.adoc#oauth2-authorization-consent-service[`OAuth2AuthorizationConsentService`] that is composed of 2x `JdbcOAuth2AuthorizationConsentService` instances, where each instance is mapped to an issuer identifier:
<4> Obtain the `JdbcOAuth2AuthorizationConsentService` that is mapped to the _"requested"_ issuer identifier indicated by `AuthorizationServerContext.getIssuer()`.
108
136
109
137
[[multi-tenant-jwk-source]]
110
-
== Multi-tenant JWKSource
138
+
=== Multi-tenant JWKSource
111
139
112
140
And finally, the following example shows a sample implementation of a `JWKSource<SecurityContext>` that is composed of 2x `JWKSet` instances, where each instance is mapped to an issuer identifier:
0 commit comments