Skip to content

chore: Rbac errors should be returned, and not hidden behind 404 #7122

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

Merged
merged 5 commits into from
Apr 13, 2023

Conversation

Emyrk
Copy link
Member

@Emyrk Emyrk commented Apr 13, 2023

sql.ErrNoRows was hiding actual errors. This makes dbauthz return actual unauthorized errors, and the api just needs to check both sql.ErrNoRows and dbauthz.IsUnauthorized to return a 404.

Fixes: #6774

@Emyrk Emyrk marked this pull request as ready for review April 13, 2023 15:55
@Emyrk Emyrk requested review from johnstcn and kylecarbs April 13, 2023 15:55
@@ -224,7 +224,7 @@ func (api *API) provisionerJobResources(rw http.ResponseWriter, r *http.Request,
}

// nolint:gocritic // GetWorkspaceAppsByAgentIDs is a system function.
apps, err := api.Database.GetWorkspaceAppsByAgentIDs(ctx, resourceAgentIDs)
apps, err := api.Database.GetWorkspaceAppsByAgentIDs(dbauthz.AsSystemRestricted(ctx), resourceAgentIDs)
Copy link
Member

Choose a reason for hiding this comment

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

Ooops, I missed this

Copy link
Member Author

Choose a reason for hiding this comment

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

The sql.ErrNoRows hid it ☹️

@Emyrk Emyrk merged commit 38e5b96 into main Apr 13, 2023
@Emyrk Emyrk deleted the stevenmasley/rbac_error branch April 13, 2023 18:06
@github-actions github-actions bot locked and limited conversation to collaborators Apr 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix DBAuthz return sql.ErrNoRows
2 participants