File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed
oauth2-authorization-server/src
main/java/org/springframework/security/oauth2/server/authorization/config/annotation/web/configurers
test/java/org/springframework/security/oauth2/server/authorization/config/annotation/web/configurers Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 5555import org .springframework .security .web .util .matcher .OrRequestMatcher ;
5656import org .springframework .security .web .util .matcher .RequestMatcher ;
5757import org .springframework .util .Assert ;
58+ import org .springframework .util .StringUtils ;
5859
5960/**
6061 * An {@link AbstractHttpConfigurer} for OAuth 2.0 Authorization Server support.
@@ -387,6 +388,9 @@ private static void validateAuthorizationServerSettings(AuthorizationServerSetti
387388 } catch (Exception ex ) {
388389 throw new IllegalArgumentException ("issuer must be a valid URL" , ex );
389390 }
391+ if (StringUtils .hasText (issuerUri .getPath ())) {
392+ throw new IllegalArgumentException ("Path component for issuer ('" + issuerUri .getPath () + "') is currently not supported" );
393+ }
390394 // rfc8414 https://datatracker.ietf.org/doc/html/rfc8414#section-2
391395 if (issuerUri .getQuery () != null || issuerUri .getFragment () != null ) {
392396 throw new IllegalArgumentException ("issuer cannot contain query or fragment component" );
Original file line number Diff line number Diff line change @@ -162,6 +162,13 @@ public void loadContextWhenIssuerNotValidUriThenThrowException() {
162162 );
163163 }
164164
165+ @ Test
166+ public void loadContextWhenIssuerWithPathThenThrowException () {
167+ assertThatThrownBy (
168+ () -> this .spring .register (AuthorizationServerConfigurationWithIssuerPath .class ).autowire ()
169+ );
170+ }
171+
165172 @ Test
166173 public void loadContextWhenIssuerWithQueryThenThrowException () {
167174 assertThatThrownBy (
@@ -183,6 +190,13 @@ public void loadContextWhenIssuerWithQueryAndFragmentThenThrowException() {
183190 );
184191 }
185192
193+ @ Test
194+ public void loadContextWhenIssuerWithEmptyPathThenThrowException () {
195+ assertThatThrownBy (
196+ () -> this .spring .register (AuthorizationServerConfigurationWithIssuerEmptyPath .class ).autowire ()
197+ );
198+ }
199+
186200 @ Test
187201 public void loadContextWhenIssuerWithEmptyQueryThenThrowException () {
188202 assertThatThrownBy (
@@ -300,6 +314,15 @@ AuthorizationServerSettings authorizationServerSettings() {
300314 }
301315 }
302316
317+ @ EnableWebSecurity
318+ static class AuthorizationServerConfigurationWithIssuerPath extends AuthorizationServerConfiguration {
319+
320+ @ Bean
321+ AuthorizationServerSettings authorizationServerSettings () {
322+ return AuthorizationServerSettings .builder ().issuer (ISSUER_URL + "/issuer1" ).build ();
323+ }
324+ }
325+
303326 @ EnableWebSecurity
304327 static class AuthorizationServerConfigurationWithIssuerQuery extends AuthorizationServerConfiguration {
305328
@@ -327,6 +350,15 @@ AuthorizationServerSettings authorizationServerSettings() {
327350 }
328351 }
329352
353+ @ EnableWebSecurity
354+ static class AuthorizationServerConfigurationWithIssuerEmptyPath extends AuthorizationServerConfiguration {
355+
356+ @ Bean
357+ AuthorizationServerSettings authorizationServerSettings () {
358+ return AuthorizationServerSettings .builder ().issuer (ISSUER_URL + "/" ).build ();
359+ }
360+ }
361+
330362 @ EnableWebSecurity
331363 static class AuthorizationServerConfigurationWithIssuerEmptyQuery extends AuthorizationServerConfiguration {
332364
You can’t perform that action at this time.
0 commit comments