Skip to content

Allow users to set auth token expiration#3479

Open
williamjallen wants to merge 1 commit intoKitware:masterfrom
williamjallen:custom-authtoken-expiration
Open

Allow users to set auth token expiration#3479
williamjallen wants to merge 1 commit intoKitware:masterfrom
williamjallen:custom-authtoken-expiration

Conversation

@williamjallen
Copy link
Collaborator

The TOKEN_DURATION environment variable is used to set the length of time authentication tokens are valid. This commit changes TOKEN_DURATION to be an upper bound on token duration, allowing users to set shorter durations.

The `TOKEN_DURATION` environment variable is used to set the length of time authentication tokens are valid.  This commit changes `TOKEN_DURATION` to be an upper bound on token duration, allowing users to set shorter durations.
Copy link
Member

@josephsnyder josephsnyder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update, Will. I've got a few things that I'd like to see thought about again.

if (!is_numeric($duration) || (int) $duration < 0) {
Log::error("Invalid token_duration configuration {$duration}");
throw new InvalidArgumentException('Invalid token_duration configuration');
// The default expiration date is 1 year in the future.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default expiration date seems to be 6 months. This token was created today with no entries in the expiration date widget. It also states 6 months in the .env description for token length

Image

<input
v-model="tokenexpiration"
type="date"
:min="minTokenExpiration"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we drop the max parameter? While it does nicely disable the dates on the calendar itself, it doesn't seem to stop the other parts of the widget from scrolling into those months or selecting them in the dropdown:

Image

It just looks incomplete

} else {
$params['expires'] = gmdate(FMT_DATETIME, $now + $duration);
if ($expiration->isNowOrPast()) {
throw new InvalidArgumentException('Token expiration cannot be in the past.');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error should probably bubble up to the user. AFAICT, it appears in the network and console tabs, but the page isn't updated to tell the user why their token wasn't created.

throw new InvalidArgumentException('Token expiration cannot be in the past.');
}

$params['expires'] = $expiration->min(self::getMaximumTokenExpiration())->toIso8601String();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should a token set to some to beyond the maximum also be an invalid argument? Creating a token for a year or two from now and creating it with a different date without an indication of the difference seems like a recipe for confusion. It might be a personal preference rather than a universal experience

Image

@williamjallen williamjallen modified the milestones: v4.10, v4.11 Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants