Skip to content

Commit 1a4602c

Browse files
hammadirshadjgrandja
authored andcommitted
Add mapping for DPoP in DefaultMapOAuth2AccessTokenResponseConverter
Closes gh-16806 Signed-off-by: muha <[email protected]>
1 parent 126cb71 commit 1a4602c

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2025 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.
@@ -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

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2025 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.
@@ -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)