Skip to content

Commit b0b97fb

Browse files
opcoocwilkinsona
authored andcommitted
Add configuration property to allow multiple issuers
See gh-41355
1 parent f7780b4 commit b0b97fb

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/server/servlet/OAuth2AuthorizationServerProperties.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,30 @@ public class OAuth2AuthorizationServerProperties implements InitializingBean {
4242
*/
4343
private String issuer;
4444

45+
/**
46+
* Set to {@code true} if multiple issuers are allowed per host. Using path
47+
* components in the URL of the issuer identifier enables supporting multiple
48+
* issuers per host in a multi-tenant hosting configuration.
49+
*
50+
* <p>
51+
* For example:
52+
* <ul>
53+
* <li>{@code https://example.com/issuer1}</li>
54+
* <li>{@code https://example.com/authz/issuer2}</li>
55+
* </ul>
56+
*
57+
* <p>
58+
* <b>NOTE:</b> Explicitly configuring the issuer identifier via
59+
* {@link #issuer(String)} forces to a single-tenant configuration. Avoid
60+
* configuring the issuer identifier when using a multi-tenant hosting
61+
* configuration, allowing the issuer identifier to be resolved from the
62+
* <i>"current"</i> request.
63+
* @param multipleIssuersAllowed {@code true} if multiple issuers are allowed per
64+
* host, {@code false} otherwise
65+
* @return the {@link Builder} for further configuration
66+
*/
67+
private boolean multipleIssuersAllowed = false;
68+
4569
/**
4670
* Registered clients of the Authorization Server.
4771
*/

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/server/servlet/OAuth2AuthorizationServerPropertiesMapper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ AuthorizationServerSettings asAuthorizationServerSettings() {
5151
OAuth2AuthorizationServerProperties.Endpoint endpoint = this.properties.getEndpoint();
5252
OAuth2AuthorizationServerProperties.OidcEndpoint oidc = endpoint.getOidc();
5353
AuthorizationServerSettings.Builder builder = AuthorizationServerSettings.builder();
54-
map.from(this.properties::getIssuer).to(builder::issuer);
54+
map.from(this.properties::getIssuer).whenHasText().to(builder::issuer);
55+
map.from(this.properties::isMultipleIssuersAllowed).to(builder::multipleIssuersAllowed);
5556
map.from(endpoint::getAuthorizationUri).to(builder::authorizationEndpoint);
5657
map.from(endpoint::getDeviceAuthorizationUri).to(builder::deviceAuthorizationEndpoint);
5758
map.from(endpoint::getDeviceVerificationUri).to(builder::deviceVerificationEndpoint);

0 commit comments

Comments
 (0)