- Notifications
You must be signed in to change notification settings - Fork928
chore: merge apikey/token session config values#12817
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
f0710d9
cdb9ed3
282d0cd
3aa8309
863688f
9ecae23
d609db3
d3b5575
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
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 |
---|---|---|
@@ -84,7 +84,7 @@ func (api *API) postToken(rw http.ResponseWriter, r *http.Request) { | ||
cookie, key, err := api.createAPIKey(ctx, apikey.CreateParams{ | ||
UserID: user.ID, | ||
LoginType: database.LoginTypeToken, | ||
DefaultLifetime: api.DeploymentValues.Sessions.DefaultDuration.Value(), | ||
ExpiresAt: dbtime.Now().Add(lifeTime), | ||
Scope: scope, | ||
LifetimeSeconds: int64(lifeTime.Seconds()), | ||
@@ -128,7 +128,7 @@ func (api *API) postAPIKey(rw http.ResponseWriter, r *http.Request) { | ||
lifeTime := time.Hour * 24 * 7 | ||
cookie, _, err := api.createAPIKey(ctx, apikey.CreateParams{ | ||
UserID: user.ID, | ||
DefaultLifetime: api.DeploymentValues.Sessions.DefaultDuration.Value(), | ||
LoginType: database.LoginTypePassword, | ||
RemoteAddr: r.RemoteAddr, | ||
// All api generated keys will last 1 week. Browser login tokens have | ||
@@ -354,7 +354,7 @@ func (api *API) tokenConfig(rw http.ResponseWriter, r *http.Request) { | ||
httpapi.Write( | ||
r.Context(), rw, http.StatusOK, | ||
codersdk.TokenConfig{ | ||
MaxTokenLifetime: values.Sessions.MaximumTokenDuration.Value(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Instead of grouping this config value with sessions, should we leave it as is before? The naming discrepancy here is confusing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I really want to group all concepts of a "Session" from the configuration perspective. Essentially we have these different things, "token", vs "cli auth", vs "browser api key". They are all "Sessions", but we do not have good documentation what the differences are. If I omit I agree the current names are confusing, and I actually had this PR fixing the names, but the I could rename | ||
}, | ||
) | ||
} | ||
@@ -364,10 +364,10 @@ func (api *API) validateAPIKeyLifetime(lifetime time.Duration) error { | ||
return xerrors.New("lifetime must be positive number greater than 0") | ||
} | ||
if lifetime > api.DeploymentValues.Sessions.MaximumTokenDuration.Value() { | ||
return xerrors.Errorf( | ||
"lifetime must be less than %v", | ||
api.DeploymentValues.Sessions.MaximumTokenDuration, | ||
) | ||
} | ||
Uh oh!
There was an error while loading.Please reload this page.