mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add API key scope to restrict access to user data (#17692)
This commit is contained in:
@@ -2140,6 +2140,11 @@ func InsertWorkspaceResource(ctx context.Context, db database.Store, jobID uuid.
|
||||
}
|
||||
}
|
||||
|
||||
apiKeyScope := database.AgentKeyScopeEnumAll
|
||||
if prAgent.ApiKeyScope == string(database.AgentKeyScopeEnumNoUserData) {
|
||||
apiKeyScope = database.AgentKeyScopeEnumNoUserData
|
||||
}
|
||||
|
||||
agentID := uuid.New()
|
||||
dbAgent, err := db.InsertWorkspaceAgent(ctx, database.InsertWorkspaceAgentParams{
|
||||
ID: agentID,
|
||||
@@ -2162,6 +2167,7 @@ func InsertWorkspaceResource(ctx context.Context, db database.Store, jobID uuid.
|
||||
ResourceMetadata: pqtype.NullRawMessage{},
|
||||
// #nosec G115 - Order represents a display order value that's always small and fits in int32
|
||||
DisplayOrder: int32(prAgent.Order),
|
||||
APIKeyScope: apiKeyScope,
|
||||
})
|
||||
if err != nil {
|
||||
return xerrors.Errorf("insert agent: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user