Skip to content

Commit 5783cd5

Browse files
vpavicsnicoll
authored andcommitted
Fix JWT token URI derivation
Closes gh-7299
1 parent 4311cf3 commit 5783cd5

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerProperties.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2015 the original author or authors.
2+
* Copyright 2012-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -246,7 +246,7 @@ public String getKeyUri() {
246246
if (ResourceServerProperties.this.tokenInfoUri != null
247247
&& ResourceServerProperties.this.tokenInfoUri
248248
.endsWith("/check_token")) {
249-
return ResourceServerProperties.this.userInfoUri.replace("/check_token",
249+
return ResourceServerProperties.this.tokenInfoUri.replace("/check_token",
250250
"/token_key");
251251
}
252252
return null;

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerPropertiesTests.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
* Tests for {@link ResourceServerProperties}.
2828
*
2929
* @author Dave Syer
30+
* @author Vedran Pavic
3031
*/
3132
public class ResourceServerPropertiesTests {
3233

@@ -45,9 +46,17 @@ public void json() throws Exception {
4546
}
4647

4748
@Test
48-
public void tokenKeyDerived() throws Exception {
49+
public void tokenKeyDerivedFromUserInfoUri() throws Exception {
4950
this.properties.setUserInfoUri("http://example.com/userinfo");
50-
assertThat(this.properties.getJwt().getKeyUri()).isNotNull();
51+
assertThat(this.properties.getJwt().getKeyUri())
52+
.isEqualTo("http://example.com/token_key");
53+
}
54+
55+
@Test
56+
public void tokenKeyDerivedFromTokenInfoUri() throws Exception {
57+
this.properties.setTokenInfoUri("http://example.com/check_token");
58+
assertThat(this.properties.getJwt().getKeyUri())
59+
.isEqualTo("http://example.com/token_key");
5160
}
5261

5362
}

0 commit comments

Comments
 (0)