- Notifications
You must be signed in to change notification settings - Fork928
feat: add session expiry control flags#5976
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
2456f05
8df63c0
9420290
adeb9b6
7a698c9
4f043f3
4239c7d
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -486,7 +486,7 @@ func newConfig() *codersdk.DeploymentConfig { | ||
}, | ||
MaxTokenLifetime: &codersdk.DeploymentConfigField[time.Duration]{ | ||
Name: "Max Token Lifetime", | ||
Usage: "The maximum lifetime durationusers can specify whencreatingan API token.", | ||
Flag: "max-token-lifetime", | ||
Default: 24 * 30 * time.Hour, | ||
}, | ||
@@ -538,6 +538,18 @@ func newConfig() *codersdk.DeploymentConfig { | ||
Flag: "disable-path-apps", | ||
Default: false, | ||
}, | ||
SessionDuration: &codersdk.DeploymentConfigField[time.Duration]{ | ||
deansheather marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
Name: "Session Duration", | ||
Usage: "The token expiry duration for browser sessions. Sessions may last longer if they are actively making requests, but this functionality can be disabled via --disable-session-expiry-refresh.", | ||
Flag: "session-duration", | ||
Default: 24 * time.Hour, | ||
}, | ||
DisableSessionExpiryRefresh: &codersdk.DeploymentConfigField[bool]{ | ||
Name: "Disable Session Expiry Refresh", | ||
Usage: "Disable automatic session expiry bumping due to activity. This forces all sessions to become invalid after the session expiry duration has been reached.", | ||
Flag: "disable-session-expiry-refresh", | ||
Default: false, | ||
}, | ||
} | ||
} | ||
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -733,23 +733,18 @@ func (api *API) workspaceApplicationAuth(rw http.ResponseWriter, r *http.Request | ||
} | ||
// Create the application_connect-scoped API key with the same lifetime as | ||
// the current session. | ||
exp := apiKey.ExpiresAt | ||
lifetimeSeconds := apiKey.LifetimeSeconds | ||
if exp.IsZero() || time.Until(exp) > api.DeploymentConfig.SessionDuration.Value { | ||
exp = database.Now().Add(api.DeploymentConfig.SessionDuration.Value) | ||
lifetimeSeconds = int64(api.DeploymentConfig.SessionDuration.Value.Seconds()) | ||
deansheather marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
} | ||
cookie, err := api.createAPIKey(ctx, createAPIKeyParams{ | ||
UserID: apiKey.UserID, | ||
LoginType: database.LoginTypePassword, | ||
ExpiresAt: exp, | ||
LifetimeSeconds:lifetimeSeconds, | ||
Scope: database.APIKeyScopeApplicationConnect, | ||
}) | ||
if err != nil { | ||
Uh oh!
There was an error while loading.Please reload this page.