mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: implement API key scopes database migration (#19861)
Added database migration for API key scopes. Fixes #19845
This commit is contained in:
+7
-1
@@ -1570,6 +1570,12 @@ func userOrganizationIDs(ctx context.Context, api *API, user database.User) ([]u
|
||||
}
|
||||
|
||||
func convertAPIKey(k database.APIKey) codersdk.APIKey {
|
||||
// Derive a single scope from arrays for response compatibility.
|
||||
scope := database.APIKeyScopeAll
|
||||
if k.Scopes.Has(database.APIKeyScopeApplicationConnect) {
|
||||
scope = database.APIKeyScopeApplicationConnect
|
||||
}
|
||||
|
||||
return codersdk.APIKey{
|
||||
ID: k.ID,
|
||||
UserID: k.UserID,
|
||||
@@ -1578,7 +1584,7 @@ func convertAPIKey(k database.APIKey) codersdk.APIKey {
|
||||
CreatedAt: k.CreatedAt,
|
||||
UpdatedAt: k.UpdatedAt,
|
||||
LoginType: codersdk.LoginType(k.LoginType),
|
||||
Scope: codersdk.APIKeyScope(k.Scope),
|
||||
Scope: codersdk.APIKeyScope(scope),
|
||||
LifetimeSeconds: k.LifetimeSeconds,
|
||||
TokenName: k.TokenName,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user