- Notifications
You must be signed in to change notification settings - Fork1k
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
base:thomask33/09-25-feat_add_allow_list_field_api_keys
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -51,6 +51,17 @@ func ListLazy[F any, T any](convert func(F) T) func(list []F) []T { | ||
} | ||
} | ||
func APIAllowListTarget(entry rbac.AllowListElement) codersdk.APIAllowListTarget { | ||
target := codersdk.AllowAllTarget() | ||
if entry.Type != "" { | ||
target.Type = codersdk.RBACResource(entry.Type) | ||
} | ||
if entry.ID != "" { | ||
target.ID = entry.ID | ||
} | ||
return target | ||
} | ||
Comment on lines +54 to +63 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 the I think we should just pass the rbac entry to the SDK as is. Do not do: | ||
type ExternalAuthMeta struct { | ||
Authenticated bool | ||
ValidateError string | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1596,6 +1596,11 @@ func convertAPIKey(k database.APIKey) codersdk.APIKey { | ||
scopes = append(scopes, codersdk.APIKeyScope(s)) | ||
} | ||
allowList := db2sdk.List(k.AllowList, db2sdk.APIAllowListTarget) | ||
if len(allowList) == 0 { | ||
allowList = append(allowList, codersdk.AllowAllTarget()) | ||
Comment on lines +1599 to +1601 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 to | ||
} | ||
return codersdk.APIKey{ | ||
ID: k.ID, | ||
UserID: k.UserID, | ||
@@ -1608,5 +1613,6 @@ func convertAPIKey(k database.APIKey) codersdk.APIKey { | ||
Scopes: scopes, | ||
LifetimeSeconds: k.LifetimeSeconds, | ||
TokenName: k.TokenName, | ||
AllowList: allowList, | ||
} | ||
} |
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.