Skip to content

feat: add default resource types to composite API key scopes#20412

Closed
ThomasK33 wants to merge 1 commit into
mainfrom
thomask33/10-22-enhance_composite_scope_defaults
Closed

feat: add default resource types to composite API key scopes#20412
ThomasK33 wants to merge 1 commit into
mainfrom
thomask33/10-22-enhance_composite_scope_defaults

Conversation

@ThomasK33
Copy link
Copy Markdown
Member

Add automatic template access to workspace API tokens

This PR enhances API tokens with composite scopes like coder:workspaces.create to automatically include required resource types in their allow lists. For example, when a user creates a token with coder:workspaces.create scope and only specifies a workspace ID in the allow list, the system now automatically adds template access, which is required for workspace creation.

The implementation:

  1. Adds a DefaultAllowIDList to composite scopes to define required resource types
  2. Introduces collectCompositeDefaults() to gather defaults from all scopes in a token
  3. Adds MergeDefaultsForMissingTypes() to apply defaults only for resource types not already in the allow list
  4. Improves authorization logging by including the allow list in error logs

This change makes API tokens more intuitive to use, as users no longer need to manually specify all required resource types for composite operations.

Copy link
Copy Markdown
Member Author

ThomasK33 commented Oct 22, 2025

@ThomasK33 ThomasK33 force-pushed the thomask33/10-22-enhance_composite_scope_defaults branch from 98d793b to 15ca185 Compare October 22, 2025 14:18
@ThomasK33 ThomasK33 marked this pull request as ready for review October 22, 2025 14:35
@ThomasK33 ThomasK33 requested a review from Emyrk as a code owner October 22, 2025 14:35
@ThomasK33 ThomasK33 force-pushed the thomask33/09-26-add_token_scope_support_in_cli branch from d2ce8e3 to d7a97c4 Compare October 23, 2025 13:08
@ThomasK33 ThomasK33 force-pushed the thomask33/10-22-enhance_composite_scope_defaults branch 2 times, most recently from 0c46ac0 to cd93ff5 Compare October 23, 2025 13:29
@ThomasK33 ThomasK33 force-pushed the thomask33/09-26-add_token_scope_support_in_cli branch from d7a97c4 to 26ce0ed Compare October 23, 2025 13:29
@ThomasK33 ThomasK33 force-pushed the thomask33/09-26-add_token_scope_support_in_cli branch from 26ce0ed to b5682aa Compare October 23, 2025 16:57
@ThomasK33 ThomasK33 force-pushed the thomask33/10-22-enhance_composite_scope_defaults branch 2 times, most recently from da7b92e to 76abe40 Compare October 23, 2025 17:05
@ThomasK33 ThomasK33 force-pushed the thomask33/09-26-add_token_scope_support_in_cli branch 3 times, most recently from ddaca3e to 9ab5bfc Compare October 24, 2025 11:34
@ThomasK33 ThomasK33 force-pushed the thomask33/10-22-enhance_composite_scope_defaults branch from 76abe40 to 11ce594 Compare October 24, 2025 11:34
@ThomasK33 ThomasK33 force-pushed the thomask33/09-26-add_token_scope_support_in_cli branch from 9ab5bfc to eb8817a Compare October 24, 2025 14:20
@ThomasK33 ThomasK33 force-pushed the thomask33/10-22-enhance_composite_scope_defaults branch from 11ce594 to a6683ad Compare October 24, 2025 14:20
@ThomasK33 ThomasK33 force-pushed the thomask33/09-26-add_token_scope_support_in_cli branch from eb8817a to 16cf91a Compare October 24, 2025 14:25
@ThomasK33 ThomasK33 force-pushed the thomask33/10-22-enhance_composite_scope_defaults branch from a6683ad to c928597 Compare October 24, 2025 14:53
@ThomasK33 ThomasK33 force-pushed the thomask33/09-26-add_token_scope_support_in_cli branch from 16cf91a to 33ee2a4 Compare October 24, 2025 14:53
@ThomasK33 ThomasK33 force-pushed the thomask33/10-22-enhance_composite_scope_defaults branch from c928597 to ef4433c Compare October 24, 2025 16:45
@ThomasK33 ThomasK33 force-pushed the thomask33/09-26-add_token_scope_support_in_cli branch from 33ee2a4 to 6bdcaf5 Compare October 24, 2025 16:45
@ThomasK33 ThomasK33 force-pushed the thomask33/10-22-enhance_composite_scope_defaults branch from ef4433c to f6de31a Compare October 27, 2025 15:18
@ThomasK33 ThomasK33 force-pushed the thomask33/09-26-add_token_scope_support_in_cli branch from 6bdcaf5 to e41d7f4 Compare October 27, 2025 15:18
@ThomasK33 ThomasK33 changed the base branch from thomask33/09-26-add_token_scope_support_in_cli to graphite-base/20412 October 27, 2025 16:07
@ThomasK33 ThomasK33 force-pushed the thomask33/10-22-enhance_composite_scope_defaults branch 2 times, most recently from 46da335 to 4156c95 Compare October 28, 2025 08:08
Ensure composite scopes retain required defaults when merging API keys.
Add MergeDefaultsForMissingTypes to union composite defaults safely.
Cover API key scope expansion and allow list merging with unit tests.
Expose SafeAllowList in Subject logging and register user:read scope.
@ThomasK33 ThomasK33 force-pushed the thomask33/10-22-enhance_composite_scope_defaults branch from 4156c95 to 6bdc93e Compare October 28, 2025 13:48
@ThomasK33 ThomasK33 changed the base branch from graphite-base/20412 to main October 28, 2025 13:48
@ThomasK33 ThomasK33 marked this pull request as draft October 28, 2025 15:40
@github-actions github-actions Bot added the stale This issue is like stale bread. label Nov 5, 2025
@github-actions github-actions Bot closed this Nov 9, 2025
@github-actions github-actions Bot deleted the thomask33/10-22-enhance_composite_scope_defaults branch April 29, 2026 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale This issue is like stale bread.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant