Skip to content

Commit

Permalink
Use default AT/RT lifetime
Browse files Browse the repository at this point in the history
when a client request trough API does not explicit one
  • Loading branch information
federicaagostini committed Sep 11, 2023
1 parent 5d77475 commit 9f9c2bf
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import it.infn.mw.iam.api.common.client.RegisteredClientDTO;
import it.infn.mw.iam.api.common.client.TokenEndpointAuthenticationMethod;
import it.infn.mw.iam.config.IamProperties;
import it.infn.mw.iam.config.client_registration.ClientRegistrationProperties;

@Component
public class ClientConverter {
Expand All @@ -46,11 +47,14 @@ public class ClientConverter {

private final String clientRegistrationBaseUrl;

private final ClientRegistrationProperties clientProperties;

@Autowired
public ClientConverter(IamProperties properties) {
public ClientConverter(IamProperties properties, ClientRegistrationProperties clientProperties) {
this.iamProperties = properties;
clientRegistrationBaseUrl =
String.format("%s%s", iamProperties.getBaseUrl(), ClientRegistrationApiController.ENDPOINT);
this.clientProperties = clientProperties;
}

private <T> Set<T> cloneSet(Set<T> stringSet) {
Expand Down Expand Up @@ -228,12 +232,18 @@ public ClientDetailsEntity entityFromRegistrationRequest(RegisteredClientDTO dto
client.setCodeChallengeMethod(pkceAlgo);
}

if (dto.getAccessTokenValiditySeconds() != null) {
if (!isNull(dto.getAccessTokenValiditySeconds())) {
client.setAccessTokenValiditySeconds(dto.getAccessTokenValiditySeconds());
} else {
client.setAccessTokenValiditySeconds(
clientProperties.getClientDefaults().getDefaultAccessTokenValiditySeconds());
}
if (dto.getRefreshTokenValiditySeconds() != null) {

if (!isNull(dto.getRefreshTokenValiditySeconds())) {
client.setRefreshTokenValiditySeconds(dto.getRefreshTokenValiditySeconds());
} else {
client.setRefreshTokenValiditySeconds(
clientProperties.getClientDefaults().getDefaultRefreshTokenValiditySeconds());
}

return client;
Expand Down

0 comments on commit 9f9c2bf

Please sign in to comment.