Skip to content

Commit 41d7425

Browse files
Add session idle lifetime and make session lifetime doubles (#423)
* Add session idle lifetime and make session lifetime doubles * fix failing test * convert back lifetimes to integer * Update src/main/java/com/auth0/json/mgmt/tenants/Tenant.java Co-authored-by: Jim Anderson <jim.anderson@auth0.com> Co-authored-by: Jim Anderson <jimranderson@gmail.com>
1 parent eb1510f commit 41d7425

3 files changed

Lines changed: 33 additions & 5 deletions

File tree

src/main/java/com/auth0/json/mgmt/tenants/Tenant.java

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ public class Tenant {
4040
@JsonProperty("session_lifetime")
4141
private Integer sessionLifetime;
4242

43+
@JsonProperty("idle_session_lifetime")
44+
private Integer idleSessionLifetime;
45+
4346
/**
4447
* Getter for the change password page customization.
4548
*
@@ -263,7 +266,7 @@ public void setAllowedLogoutUrls(List<String> allowedLogoutUrls) {
263266
/**
264267
* Getter for the login session lifetime. This is how long the session will stay valid. Value is in hours.
265268
*
266-
* @return the session life time in hours.
269+
* @return the session lifetime in hours.
267270
*/
268271
@JsonProperty("session_lifetime")
269272
public Integer getSessionLifetime() {
@@ -273,10 +276,30 @@ public Integer getSessionLifetime() {
273276
/**
274277
* Setter for the login session lifetime. This is how long the session will stay valid. Value is in hours.
275278
*
276-
* @param sessionLifetime the session life time in hours to set.
279+
* @param sessionLifetime the session lifetime in hours to set.
277280
*/
278281
@JsonProperty("session_lifetime")
279282
public void setSessionLifetime(Integer sessionLifetime) {
280283
this.sessionLifetime = sessionLifetime;
281284
}
282-
}
285+
286+
/**
287+
* Getter for the login session idle lifetime. This is how long the session will stay valid without user activity. Value is in hours.
288+
*
289+
* @return the session idle lifetime in hours.
290+
*/
291+
@JsonProperty("idle_session_lifetime")
292+
public Integer getIdleSessionLifetime() {
293+
return idleSessionLifetime;
294+
}
295+
296+
/**
297+
* Setter for the login session idle lifetime. This is how long the session will stay valid without user activity. Value is in hours.
298+
*
299+
* @param idleSessionLifetime the session lifetime in hours to set.
300+
*/
301+
@JsonProperty("idle_session_lifetime")
302+
public void setIdleSessionLifetime(Integer idleSessionLifetime) {
303+
this.idleSessionLifetime = idleSessionLifetime;
304+
}
305+
}

src/test/java/com/auth0/json/mgmt/tenants/TenantTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
public class TenantTest extends JsonTest<Tenant> {
1414

15-
private static final String json = "{\"change_password\":{},\"guardian_mfa_page\":{},\"default_audience\":\"https://domain.auth0.com/myapi\",\"default_directory\":\"Username-Password-Authentication\",\"error_page\":{},\"flags\":{},\"friendly_name\":\"My-Tenant\",\"picture_url\":\"https://pic.to/123\",\"support_email\":\"support@auth0.com\",\"support_url\":\"https://support.auth0.com\",\"allowed_logout_urls\":[\"https://domain.auth0.com/logout\"], \"session_lifetime\":24}";
15+
private static final String json = "{\"change_password\":{},\"guardian_mfa_page\":{},\"default_audience\":\"https://domain.auth0.com/myapi\",\"default_directory\":\"Username-Password-Authentication\",\"error_page\":{},\"flags\":{},\"friendly_name\":\"My-Tenant\",\"picture_url\":\"https://pic.to/123\",\"support_email\":\"support@auth0.com\",\"support_url\":\"https://support.auth0.com\",\"allowed_logout_urls\":[\"https://domain.auth0.com/logout\"], \"session_lifetime\":24, \"idle_session_lifetime\":0.5}";
1616

1717
@Test
1818
public void shouldSerialize() throws Exception {
@@ -29,6 +29,7 @@ public void shouldSerialize() throws Exception {
2929
tenant.setSupportUrl("https://support.auth0.com");
3030
tenant.setAllowedLogoutUrls(Collections.singletonList("https://domain.auth0.com/logout"));
3131
tenant.setSessionLifetime(48);
32+
tenant.setIdleSessionLifetime(0);
3233

3334
String serialized = toJSON(tenant);
3435
assertThat(serialized, is(notNullValue()));
@@ -45,6 +46,7 @@ public void shouldSerialize() throws Exception {
4546
assertThat(serialized, JsonMatcher.hasEntry("support_url", "https://support.auth0.com"));
4647
assertThat(serialized, JsonMatcher.hasEntry("allowed_logout_urls", Arrays.asList("https://domain.auth0.com/logout")));
4748
assertThat(serialized, JsonMatcher.hasEntry("session_lifetime", 48));
49+
assertThat(serialized, JsonMatcher.hasEntry("idle_session_lifetime", 0));
4850
}
4951

5052
@Test
@@ -64,6 +66,7 @@ public void shouldDeserialize() throws Exception {
6466
assertThat(tenant.getSupportUrl(), is("https://support.auth0.com"));
6567
assertThat(tenant.getAllowedLogoutUrls(), contains("https://domain.auth0.com/logout"));
6668
assertThat(tenant.getSessionLifetime(), is(24));
69+
assertThat(tenant.getIdleSessionLifetime(), is(0));
6770
}
6871

6972
}

src/test/resources/mgmt/tenant.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@
2222
"enable_dynamic_client_registration": false
2323
},
2424
"friendly_name": "My Company",
25+
"idle_session_lifetime": 0.5,
26+
"session_lifetime": 0.75,
2527
"picture_url": "https://mycompany.org/logo.png",
2628
"support_email": "support@mycompany.org",
2729
"support_url": "https://mycompany.org/support",
2830
"allowed_logout_urls": [
2931
"https://mycompany.org/logoutCallback"
3032
]
31-
}
33+
}

0 commit comments

Comments
 (0)