Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add API key scope to restrict access to user data#17692

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

Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletionscoderd/coderd.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -802,6 +802,11 @@ func New(options *Options) *API {
PostAuthAdditionalHeadersFunc:options.PostAuthAdditionalHeadersFunc,
})

workspaceAgentInfo:=httpmw.ExtractWorkspaceAgentAndLatestBuild(httpmw.ExtractWorkspaceAgentAndLatestBuildConfig{
DB:options.Database,
Optional:false,
})
Comment on lines +805 to +808
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

If this is only used once, we can probably go back to doing it inline, rather than declaring it up here.

Just a nit


// API rate limit middleware. The counter is local and not shared between
// replicas or instances of this middleware.
apiRateLimiter:=httpmw.RateLimit(options.APIRateLimit,time.Minute)
Expand DownExpand Up@@ -1289,10 +1294,7 @@ func New(options *Options) *API {
httpmw.RequireAPIKeyOrWorkspaceProxyAuth(),
).Get("/connection",api.workspaceAgentConnectionGeneric)
r.Route("/me",func(r chi.Router) {
r.Use(httpmw.ExtractWorkspaceAgentAndLatestBuild(httpmw.ExtractWorkspaceAgentAndLatestBuildConfig{
DB:options.Database,
Optional:false,
}))
r.Use(workspaceAgentInfo)
r.Get("/rpc",api.workspaceAgentRPC)
r.Patch("/logs",api.patchWorkspaceAgentLogs)
r.Patch("/app-status",api.patchWorkspaceAgentAppStatus)
Expand Down
5 changes: 3 additions & 2 deletionscoderd/database/dbauthz/dbauthz_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4018,8 +4018,9 @@ func (s *MethodTestSuite) TestSystemFunctions() {
s.Run("InsertWorkspaceAgent",s.Subtest(func(db database.Store,check*expects) {
dbtestutil.DisableForeignKeysAndTriggers(s.T(),db)
check.Args(database.InsertWorkspaceAgentParams{
ID:uuid.New(),
Name:"dev",
ID:uuid.New(),
Name:"dev",
APIKeyScope:database.AgentKeyScopeEnumAll,
}).Asserts(rbac.ResourceSystem,policy.ActionCreate)
}))
s.Run("InsertWorkspaceApp",s.Subtest(func(db database.Store,check*expects) {
Expand Down
1 change: 1 addition & 0 deletionscoderd/database/dbgen/dbgen.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -212,6 +212,7 @@ func WorkspaceAgent(t testing.TB, db database.Store, orig database.WorkspaceAgen
MOTDFile:takeFirst(orig.TroubleshootingURL,""),
DisplayApps:append([]database.DisplayApp{},orig.DisplayApps...),
DisplayOrder:takeFirst(orig.DisplayOrder,1),
APIKeyScope:takeFirst(orig.APIKeyScope,database.AgentKeyScopeEnumAll),
})
require.NoError(t,err,"insert workspace agent")
returnagt
Expand Down
1 change: 1 addition & 0 deletionscoderd/database/dbmem/dbmem.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9620,6 +9620,7 @@ func (q *FakeQuerier) InsertWorkspaceAgent(_ context.Context, arg database.Inser
LifecycleState:database.WorkspaceAgentLifecycleStateCreated,
DisplayApps:arg.DisplayApps,
DisplayOrder:arg.DisplayOrder,
APIKeyScope:arg.APIKeyScope,
}

q.workspaceAgents=append(q.workspaceAgents,agent)
Expand Down
8 changes: 8 additions & 0 deletionscoderd/database/dump.sql
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
-- Remove the api_key_scope column from the workspace_agents table
ALTERTABLE workspace_agents
DROP COLUMN IF EXISTS api_key_scope;

-- Drop the enum type for API key scope
DROPTYPE IF EXISTS agent_key_scope_enum;
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
-- Create the enum type for API key scope
CREATETYPEagent_key_scope_enumAS ENUM ('all','no_user_data');

-- Add the api_key_scope column to the workspace_agents table
-- It defaults to 'all' to maintain existing behavior for current agents.
ALTERTABLE workspace_agents
ADD COLUMN api_key_scope agent_key_scope_enumNOT NULL DEFAULT'all';

-- Add a comment explaining the purpose of the column
COMMENT ON COLUMN workspace_agents.api_key_scope IS'Defines the scope of the API key associated with the agent.''all'' allows access to everything,''no_user_data'' restricts it to exclude user data.';
60 changes: 60 additions & 0 deletionscoderd/database/models.go
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp