diff --git a/datahub-frontend/app/react/auth/AuthModule.java b/datahub-frontend/app/react/auth/AuthModule.java index be76efb02566d..39868a4e44ed1 100644 --- a/datahub-frontend/app/react/auth/AuthModule.java +++ b/datahub-frontend/app/react/auth/AuthModule.java @@ -144,7 +144,7 @@ private Result handleOidcCallback(final Result result, final PlayWebContext cont context.getJavaSession().put(ACTOR, actorUrn); return result.withCookies(createActorCookie(actorUrn, _configs.hasPath(SESSION_TTL_CONFIG_PATH) ? _configs.getInt(SESSION_TTL_CONFIG_PATH) - : DEFAULT_SESSION_TTL_DAYS)); + : DEFAULT_SESSION_TTL_HOURS)); } else { throw new RuntimeException( String.format("Failed to extract DataHub username from username claim %s using regex %s", diff --git a/datahub-frontend/app/react/auth/AuthUtils.java b/datahub-frontend/app/react/auth/AuthUtils.java index c0d1c7c869306..6abd9b416e64d 100644 --- a/datahub-frontend/app/react/auth/AuthUtils.java +++ b/datahub-frontend/app/react/auth/AuthUtils.java @@ -8,8 +8,8 @@ public class AuthUtils { - public static final String SESSION_TTL_CONFIG_PATH = "auth.session.ttlInDays"; - public static final Integer DEFAULT_SESSION_TTL_DAYS = 30; + public static final String SESSION_TTL_CONFIG_PATH = "auth.session.ttlInHours"; + public static final Integer DEFAULT_SESSION_TTL_HOURS = 720; public static final CorpuserUrn DEFAULT_ACTOR_URN = new CorpuserUrn("datahub"); public static final String LOGIN_ROUTE = "/login"; @@ -30,15 +30,15 @@ public static boolean isAuthenticated(final Http.Context ctx) { } /** - * Creates a client authentication cookie (actor cookie) with a specified TTL in days. + * Creates a client authentication cookie (actor cookie) with a specified TTL in hours. * * @param actorUrn the urn of the authenticated actor, e.g. "urn:li:corpuser:datahub" - * @param ttlInDays the number of days until the actor cookie expires after being set + * @param ttlInHours the number of hours until the actor cookie expires after being set */ - public static Http.Cookie createActorCookie(final String actorUrn, final Integer ttlInDays) { + public static Http.Cookie createActorCookie(final String actorUrn, final Integer ttlInHours) { return Http.Cookie.builder(ACTOR, actorUrn) .withHttpOnly(false) - .withMaxAge(Duration.of(ttlInDays, ChronoUnit.DAYS)) + .withMaxAge(Duration.of(ttlInHours, ChronoUnit.HOURS)) .build(); } diff --git a/datahub-frontend/app/react/controllers/AuthenticationController.java b/datahub-frontend/app/react/controllers/AuthenticationController.java index fad3b7a62048d..4a32d7f3bfe94 100644 --- a/datahub-frontend/app/react/controllers/AuthenticationController.java +++ b/datahub-frontend/app/react/controllers/AuthenticationController.java @@ -78,7 +78,7 @@ public Result authenticate() { session().put(ACTOR, DEFAULT_ACTOR_URN.toString()); return redirect("/").withCookies(createActorCookie(DEFAULT_ACTOR_URN.toString(), _configs.hasPath(SESSION_TTL_CONFIG_PATH) ? _configs.getInt(SESSION_TTL_CONFIG_PATH) - : DEFAULT_SESSION_TTL_DAYS)); + : DEFAULT_SESSION_TTL_HOURS)); } /** diff --git a/datahub-frontend/conf/application.conf b/datahub-frontend/conf/application.conf index 5e2aaf7d20441..d7d29f97301a8 100644 --- a/datahub-frontend/conf/application.conf +++ b/datahub-frontend/conf/application.conf @@ -138,6 +138,10 @@ auth.jaas.enabled = ${?AUTH_JAAS_ENABLED} # auth.jaas.enabled = false # auth.oidc.enabled = false # (or simply omit oidc configurations) +# Login session expiration time +# auth.session.ttlInHours = ${?AUTH_SESSION_TTL_HOURS} + + analytics.enabled = ${?DATAHUB_ANALYTICS_ENABLED} # Kafka Producer Configuration