Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(frontend): auth session ttl specified in hours instead of days. M… #2695

Merged
merged 4 commits into from
Jun 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion datahub-frontend/app/react/auth/AuthModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,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",
Expand Down
12 changes: 6 additions & 6 deletions datahub-frontend/app/react/auth/AuthUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/**
Expand Down
4 changes: 4 additions & 0 deletions datahub-frontend/conf/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,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
Expand Down