-
Notifications
You must be signed in to change notification settings - Fork 0
feat: list all accounts/applications regardless of access #9
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,20 +20,26 @@ type appSecretRequest struct { | |
| Value string `json:"value"` | ||
| } | ||
|
|
||
| type applicationListItem struct { | ||
| service.ApplicationWithSecretCount | ||
| CanAccess bool `json:"can_access"` | ||
| } | ||
|
|
||
| func ListApplications(c *gin.Context) { | ||
| Require(c, RequestTokenExists(c)) | ||
| applications, err := service.GetAllApplications() | ||
| if err != nil { | ||
| c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) | ||
| return | ||
| } | ||
| authorized := make([]service.ApplicationWithSecretCount, 0, len(applications)) | ||
| response := make([]applicationListItem, 0, len(applications)) | ||
| for _, application := range applications { | ||
| if RequestTokenCanAccessApplication(c, application.Application) { | ||
| authorized = append(authorized, application) | ||
| } | ||
| response = append(response, applicationListItem{ | ||
| ApplicationWithSecretCount: application, | ||
|
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.
When a caller is authenticated but not in an application's access group, this still embeds Useful? React with 👍 / 👎. |
||
| CanAccess: RequestTokenCanAccessApplication(c, application.Application), | ||
| }) | ||
| } | ||
| c.JSON(http.StatusOK, authorized) | ||
| c.JSON(http.StatusOK, response) | ||
| } | ||
|
|
||
| func GetApplication(c *gin.Context) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When an authenticated caller lacks this account's access group, the new list item still embeds the full
AccountWithSecretCount, so/accountsexposes restricted account metadata such assecret_count, URL, description, group names, and creator/updater IDs even thoughGetAccountwould reject the same caller. If access groups are used to keep an account's secret inventory private, any user can now enumerate that inventory from the list response; return a redacted item forCanAccess == falseinstead of the full counted model.Useful? React with 👍 / 👎.