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 allow list to API keys#19972

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

Open
ThomasK33 wants to merge1 commit intothomask33/09-25-feat_add_allow_list_field_api_keys
base:thomask33/09-25-feat_add_allow_list_field_api_keys
Choose a base branch
Loading
fromthomask33/09-25-resource_scoped_api_keys_in_codersdk

Conversation

ThomasK33
Copy link
Member

@ThomasK33ThomasK33 commentedSep 25, 2025
edited
Loading

Add API key allow list to the SDK

This PR adds an allow list to API keys in the SDK. The allow list is a list of targets that the API key is allowed to access. If the allow list is empty, a default allow list with a single entry that allows access to all resources is created.

The changes include:

  • Adding a default allow list when generating an API key if none is provided
  • Adding allow list to the API key response in the SDK
  • Converting database allow list entries to SDK format in the API response
  • Adding tests to verify the default allow list behavior

Fixes#19854

@ThomasK33Graphite App
Copy link
MemberAuthor

ThomasK33 commentedSep 25, 2025
edited
Loading

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stackon Graphite.
Learn more

This stack of pull requests is managed byGraphite. Learn more aboutstacking.

@ThomasK33ThomasK33 linked an issueSep 25, 2025 that may beclosed by this pull request
@ThomasK33ThomasK33force-pushed thethomask33/09-25-resource_scoped_api_keys_in_codersdk branch from05cdebd to5442fcdCompareSeptember 25, 2025 21:20
@ThomasK33ThomasK33force-pushed thethomask33/09-25-feat_add_allow_list_field_api_keys branch from1fea0d8 to8013625CompareSeptember 26, 2025 07:45
@ThomasK33ThomasK33force-pushed thethomask33/09-25-resource_scoped_api_keys_in_codersdk branch 2 times, most recently fromda32dec tof2fbea4CompareSeptember 26, 2025 08:25
@ThomasK33ThomasK33force-pushed thethomask33/09-25-feat_add_allow_list_field_api_keys branch from8013625 to4382587CompareSeptember 26, 2025 08:25
@ThomasK33ThomasK33force-pushed thethomask33/09-25-resource_scoped_api_keys_in_codersdk branch fromf2fbea4 to847f52eCompareSeptember 26, 2025 09:31
@ThomasK33ThomasK33force-pushed thethomask33/09-25-feat_add_allow_list_field_api_keys branch from4382587 tofb2440eCompareSeptember 26, 2025 10:16
@ThomasK33ThomasK33force-pushed thethomask33/09-25-resource_scoped_api_keys_in_codersdk branch from847f52e to1361b86CompareSeptember 26, 2025 10:17
@ThomasK33ThomasK33force-pushed thethomask33/09-25-feat_add_allow_list_field_api_keys branch fromfb2440e toce693c0CompareSeptember 26, 2025 10:20
@ThomasK33ThomasK33force-pushed thethomask33/09-25-resource_scoped_api_keys_in_codersdk branch from1361b86 to581bc52CompareSeptember 26, 2025 10:20
@ThomasK33ThomasK33 marked this pull request as ready for reviewSeptember 26, 2025 11:24
@ThomasK33ThomasK33force-pushed thethomask33/09-25-resource_scoped_api_keys_in_codersdk branch from581bc52 to6d17ef1CompareSeptember 26, 2025 12:24
@ThomasK33ThomasK33force-pushed thethomask33/09-25-feat_add_allow_list_field_api_keys branch fromce693c0 tof1a4e56CompareSeptember 26, 2025 12:24
@ThomasK33ThomasK33force-pushed thethomask33/09-25-feat_add_allow_list_field_api_keys branch fromf1a4e56 toa591e0aCompareSeptember 26, 2025 14:00
@ThomasK33ThomasK33force-pushed thethomask33/09-25-resource_scoped_api_keys_in_codersdk branch from6d17ef1 to6fa5fe1CompareSeptember 26, 2025 14:00
@ThomasK33ThomasK33force-pushed thethomask33/09-25-resource_scoped_api_keys_in_codersdk branch 2 times, most recently fromc8a7549 toc50a0acCompareOctober 1, 2025 13:56
@ThomasK33ThomasK33force-pushed thethomask33/09-25-feat_add_allow_list_field_api_keys branch from276874b to662f3faCompareOctober 2, 2025 07:35
@ThomasK33ThomasK33force-pushed thethomask33/09-25-resource_scoped_api_keys_in_codersdk branch 2 times, most recently from56cd860 tod38ed5bCompareOctober 2, 2025 17:37
@ThomasK33ThomasK33force-pushed thethomask33/09-25-feat_add_allow_list_field_api_keys branch 3 times, most recently from5dd3400 to5a6e8ccCompareOctober 3, 2025 17:59
@ThomasK33ThomasK33force-pushed thethomask33/09-25-resource_scoped_api_keys_in_codersdk branch fromd38ed5b to5cb53f7CompareOctober 3, 2025 17:59
@ThomasK33ThomasK33force-pushed thethomask33/09-25-feat_add_allow_list_field_api_keys branch from5a6e8cc to73a65faCompareOctober 6, 2025 09:42
@ThomasK33ThomasK33force-pushed thethomask33/09-25-resource_scoped_api_keys_in_codersdk branch from5cb53f7 to6248fffCompareOctober 6, 2025 09:42
@ThomasK33ThomasK33force-pushed thethomask33/09-25-feat_add_allow_list_field_api_keys branch 2 times, most recently from7d422aa tod590c1dCompareOctober 6, 2025 10:09
@ThomasK33ThomasK33force-pushed thethomask33/09-25-resource_scoped_api_keys_in_codersdk branch from6248fff to67ed32bCompareOctober 6, 2025 10:09
@ThomasK33ThomasK33force-pushed thethomask33/09-25-feat_add_allow_list_field_api_keys branch fromd590c1d to49af2b4CompareOctober 6, 2025 10:35
@ThomasK33ThomasK33force-pushed thethomask33/09-25-resource_scoped_api_keys_in_codersdk branch 2 times, most recently from4beef99 to86f7de9CompareOctober 6, 2025 11:18
@ThomasK33ThomasK33force-pushed thethomask33/09-25-feat_add_allow_list_field_api_keys branch from49af2b4 tofa53285CompareOctober 6, 2025 11:57
@ThomasK33ThomasK33force-pushed thethomask33/09-25-resource_scoped_api_keys_in_codersdk branch from86f7de9 to854efb0CompareOctober 6, 2025 11:57
@EmyrkEmyrk self-assigned thisOct 6, 2025
@ThomasK33ThomasK33force-pushed thethomask33/09-25-feat_add_allow_list_field_api_keys branch fromfa53285 tod7df2aaCompareOctober 6, 2025 21:16
@ThomasK33ThomasK33force-pushed thethomask33/09-25-resource_scoped_api_keys_in_codersdk branch 2 times, most recently from87fb51c to3bdb267CompareOctober 6, 2025 21:40
Comment on lines +54 to +63
funcAPIAllowListTarget(entry rbac.AllowListElement) codersdk.APIAllowListTarget {
target:=codersdk.AllowAllTarget()
ifentry.Type!="" {
target.Type=codersdk.RBACResource(entry.Type)
}
ifentry.ID!="" {
target.ID=entry.ID
}
returntarget
}
Copy link
Member

Choose a reason for hiding this comment

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

I know we have to figure out the semantics of an empty string for theid, but it should not be treated as a wildcard imo.

I think we should just pass the rbac entry to the SDK as is. Do not do:target := codersdk.AllowAllTarget() as the default.

Comment on lines +1599 to +1601
allowList:=db2sdk.List(k.AllowList,db2sdk.APIAllowListTarget)
iflen(allowList)==0 {
allowList=append(allowList,codersdk.AllowAllTarget())
Copy link
Member

Choose a reason for hiding this comment

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

I still think we should never have an empty allow list. The db migration handles this iirc, so defaulting toall if the list is empty feels like it's hiding some other issue.

Add allow_list field to API key data structures and ensure properJSON serialization across backend and frontend. Initialize with default wildcard entry (*:*) for backward compatibility withexisting API keys that don't have explicit resource restrictions.Fixes#19854
@ThomasK33ThomasK33force-pushed thethomask33/09-25-feat_add_allow_list_field_api_keys branch fromd7df2aa toa1346f5CompareOctober 7, 2025 16:38
@ThomasK33ThomasK33force-pushed thethomask33/09-25-resource_scoped_api_keys_in_codersdk branch from3bdb267 toc41112aCompareOctober 7, 2025 16:38
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@EmyrkEmyrkEmyrk left review comments

Assignees

@ThomasK33ThomasK33

@EmyrkEmyrk

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

SDK (Go): codersdk types for scopes[] + allow_list[]
2 participants
@ThomasK33@Emyrk

[8]ページ先頭

©2009-2025 Movatter.jp