Skip to content

Commit 4eb7558

Browse files
committed
Polish "Add properties to support device grant"
See gh-34957
1 parent 25b582c commit 4eb7558

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/server/servlet/OAuth2AuthorizationServerProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ public static class Token {
459459
/**
460460
* Time-to-live for a device code.
461461
*/
462-
private Duration deviceCodeTimeToLive;
462+
private Duration deviceCodeTimeToLive = Duration.ofMinutes(5);
463463

464464
/**
465465
* Whether refresh tokens are reused or a new refresh token is issued when

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/server/servlet/OAuth2AuthorizationServerPropertiesMapperTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ void getRegisteredClientsWhenValidParametersShouldAdapt() {
6666
assertThat(registeredClient.getTokenSettings().getAccessTokenFormat()).isEqualTo(OAuth2TokenFormat.REFERENCE);
6767
assertThat(registeredClient.getTokenSettings().getAccessTokenTimeToLive()).isEqualTo(Duration.ofSeconds(300));
6868
assertThat(registeredClient.getTokenSettings().getRefreshTokenTimeToLive()).isEqualTo(Duration.ofHours(24));
69+
assertThat(registeredClient.getTokenSettings().getDeviceCodeTimeToLive()).isEqualTo(Duration.ofMinutes(30));
6970
assertThat(registeredClient.getTokenSettings().isReuseRefreshTokens()).isEqualTo(true);
7071
assertThat(registeredClient.getTokenSettings().getIdTokenSignatureAlgorithm())
7172
.isEqualTo(SignatureAlgorithm.RS512);

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/server/servlet/OAuth2AuthorizationServerPropertiesTests.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
import org.junit.jupiter.api.Test;
2020

21+
import org.springframework.security.oauth2.server.authorization.settings.TokenSettings;
22+
23+
import static org.assertj.core.api.Assertions.assertThat;
2124
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
2225

2326
/**
@@ -69,4 +72,10 @@ void authorizationGrantTypesEmptyThrowsException() {
6972
.withMessage("Authorization grant types must not be empty.");
7073
}
7174

75+
@Test
76+
void defaultDeviceCodeTimeToLiveMatchesBuilderDefault() {
77+
assertThat(new OAuth2AuthorizationServerProperties.Client().getToken().getDeviceCodeTimeToLive())
78+
.isEqualTo(TokenSettings.builder().build().getDeviceCodeTimeToLive());
79+
}
80+
7281
}

0 commit comments

Comments
 (0)