mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: Longer lived api keys for cli (#1935)
* feat: Longer lived api keys for cli * feat: Refresh tokens based on their lifetime set in the db * test: Add unit test for refreshing
This commit is contained in:
@@ -12,6 +12,7 @@ LIMIT
|
||||
INSERT INTO
|
||||
api_keys (
|
||||
id,
|
||||
lifetime_seconds,
|
||||
hashed_secret,
|
||||
user_id,
|
||||
last_used,
|
||||
@@ -25,7 +26,13 @@ INSERT INTO
|
||||
oauth_expiry
|
||||
)
|
||||
VALUES
|
||||
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12) RETURNING *;
|
||||
(@id,
|
||||
-- If the lifetime is set to 0, default to 24hrs
|
||||
CASE @lifetime_seconds::bigint
|
||||
WHEN 0 THEN 86400
|
||||
ELSE @lifetime_seconds::bigint
|
||||
END
|
||||
, @hashed_secret, @user_id, @last_used, @expires_at, @created_at, @updated_at, @login_type, @oauth_access_token, @oauth_refresh_token, @oauth_id_token, @oauth_expiry) RETURNING *;
|
||||
|
||||
-- name: UpdateAPIKeyByID :exec
|
||||
UPDATE
|
||||
|
||||
Reference in New Issue
Block a user