Skip to content

Add agent API key scope to restrict access to user data #391

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ThomasK33
Copy link
Member

@ThomasK33 ThomasK33 commented May 6, 2025

Part of coder/coder#17649


Add API Key Scope Control for Coder Agents

This PR introduces a new api_key_scope parameter for the coder_agent resource, allowing administrators to control what API routes an agent token can access. This feature enhances security by providing the option to restrict sensitive user data access.

The new parameter supports two options:

  • all: Full API access (this is the default value)
  • no_user_data: Blocks access to /external-auth, /gitsshkey, and /gitauth routes

Changes:

  • Added the api_key_scope field to the agent resource schema with validation
  • Updated documentation to reflect the new parameter
  • Added comprehensive tests for valid transitions and invalid values
  • Updated examples to demonstrate usage

Development Environment:

  • Added direnv configuration for improved developer experience
  • Updated Nix flake to use Go 1.24 and nixpkgs 24.11

This change is backward compatible as the default behavior remains unchanged.

Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@ThomasK33 ThomasK33 requested a review from Copilot May 6, 2025 09:13
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request adds an "api_key_scope" parameter to the coder agent resource, enabling administrators to restrict agent token access to sensitive routes.

  • Added a new "api_key_scope" field with validation in the provider schema.
  • Integrated comprehensive tests for valid and invalid parameter values.
  • Updated documentation examples to include the new parameter.

Reviewed Changes

Copilot reviewed 5 out of 8 changed files in this pull request and generated no comments.

File Description
provider/agent_test.go Added tests for valid transitions and error handling for the new "api_key_scope".
provider/agent.go Updated the schema for coder_agent with the new "api_key_scope" field and validation.
docs/resources/agent.md Updated documentation to demonstrate the usage of the new "api_key_scope" parameter.
Files not reviewed (3)
  • .envrc: Language not supported
  • examples/resources/coder_agent/resource.tf: Language not supported
  • flake.nix: Language not supported

@ThomasK33 ThomasK33 marked this pull request as ready for review May 7, 2025 13:58
@ThomasK33 ThomasK33 requested a review from Emyrk May 7, 2025 14:07
@ThomasK33 ThomasK33 force-pushed the thomask33/05-06-feat_agent_add_api_key_scope_to_control_agent_token_permissions branch from 446ce15 to 9861bbd Compare May 7, 2025 22:09
Change-Id: I90dd87756b47b589bf0a363e22de70d2cffd44fa
Signed-off-by: Thomas Kosiewski <tk@coder.com>
@ThomasK33 ThomasK33 force-pushed the thomask33/05-06-feat_agent_add_api_key_scope_to_control_agent_token_permissions branch from 9861bbd to fa0fe79 Compare May 7, 2025 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant