Skip to content

Commit 8699230

Browse files
author
muha
committed
Added a mapping for DPOP in DefaultMapOAuth2AccessTokenResponseConverter
1 parent 56e757a commit 8699230

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/endpoint/DefaultMapOAuth2AccessTokenResponseConverter.java

+4
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ private static OAuth2AccessToken.TokenType getAccessTokenType(Map<String, Object
7070
.equalsIgnoreCase(getParameterValue(tokenResponseParameters, OAuth2ParameterNames.TOKEN_TYPE))) {
7171
return OAuth2AccessToken.TokenType.BEARER;
7272
}
73+
else if (OAuth2AccessToken.TokenType.DPOP.getValue()
74+
.equalsIgnoreCase(getParameterValue(tokenResponseParameters, OAuth2ParameterNames.TOKEN_TYPE))) {
75+
return OAuth2AccessToken.TokenType.DPOP;
76+
}
7377
return null;
7478
}
7579

oauth2/oauth2-core/src/test/java/org/springframework/security/oauth2/core/endpoint/DefaultMapOAuth2AccessTokenResponseConverterTests.java

+12
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,18 @@ public void shouldConvertMinimal() {
9898
assertThat(additionalParameters).isEmpty();
9999
}
100100

101+
@Test
102+
public void shouldConvertDPoPToken() {
103+
Map<String, Object> map = new HashMap<>();
104+
map.put("access_token", "access-token-1234");
105+
map.put("token_type", "dpop");
106+
OAuth2AccessTokenResponse converted = this.messageConverter.convert(map);
107+
OAuth2AccessToken accessToken = converted.getAccessToken();
108+
assertThat(accessToken).isNotNull();
109+
assertThat(accessToken.getTokenValue()).isEqualTo("access-token-1234");
110+
assertThat(accessToken.getTokenType()).isEqualTo(OAuth2AccessToken.TokenType.DPOP);
111+
}
112+
101113
@Test
102114
public void shouldConvertWithUnsupportedExpiresIn() {
103115
Map<String, Object> map = new HashMap<>();

0 commit comments

Comments
 (0)