From 2dc57718ed32879e1a2e2dd13712ecfe0afe29eb Mon Sep 17 00:00:00 2001 From: hammadirshad Date: Sun, 23 Mar 2025 14:34:01 +0100 Subject: [PATCH] Added a mapping for DPOP in DefaultMapOAuth2AccessTokenResponseConverter Signed-off-by: muha --- ...faultMapOAuth2AccessTokenResponseConverter.java | 6 +++++- ...MapOAuth2AccessTokenResponseConverterTests.java | 14 +++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/endpoint/DefaultMapOAuth2AccessTokenResponseConverter.java b/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/endpoint/DefaultMapOAuth2AccessTokenResponseConverter.java index 1e2220c48f5..1e230c317a9 100644 --- a/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/endpoint/DefaultMapOAuth2AccessTokenResponseConverter.java +++ b/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/endpoint/DefaultMapOAuth2AccessTokenResponseConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -70,6 +70,10 @@ private static OAuth2AccessToken.TokenType getAccessTokenType(Map map = new HashMap<>(); + map.put("access_token", "access-token-1234"); + map.put("token_type", "dpop"); + OAuth2AccessTokenResponse converted = this.messageConverter.convert(map); + OAuth2AccessToken accessToken = converted.getAccessToken(); + assertThat(accessToken).isNotNull(); + assertThat(accessToken.getTokenValue()).isEqualTo("access-token-1234"); + assertThat(accessToken.getTokenType()).isEqualTo(OAuth2AccessToken.TokenType.DPOP); + } + @Test public void shouldConvertWithUnsupportedExpiresIn() { Map map = new HashMap<>();