-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
server: Return permission error if one occurs for Events endpoint #72416
server: Return permission error if one occurs for Events endpoint #72416
Conversation
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.
Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @koorosh and @Santamaura)
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.
Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @nathanstilwell and @Santamaura)
pkg/server/admin.go, line 1222 at r2 (raw file):
// just do it here. defer func() { if retErr != nil && error.Is(retErh, errRequiresAdmin) {
Just wondering if we need to handle the same permission error with other endpoints?
If yes, then it might be better to move this extra validation into serverError
func.
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.
LGTM, only a question to make sure if we need to make this more generic
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @nathanstilwell and @Santamaura)
pkg/server/admin.go, line 1222 at r2 (raw file):
Previously, koorosh (Andrii Vorobiov) wrote…
Just wondering if we need to handle the same permission error with other endpoints?
If yes, then it might be better to move this extra validation intoserverError
func.
func (s *adminServer) serverError(err error) error {
log.ErrorfDepth(context.TODO(), 1, "%s", err)
if error.Is(err, errRequiresAdmin {
return err
}
return errAdminAPIError
}
pkg/server/admin.go, line 1222 at r2 (raw file): Previously, koorosh (Andrii Vorobiov) wrote…
David and I talked about that, but |
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.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @Santamaura)
pkg/server/admin.go, line 1222 at r2 (raw file):
Previously, nathanstilwell (Nathan Stilwell) wrote…
David and I talked about that, but
serverError
is used in so many places I fear unintended consequences. If we find ourselves doing this in more places that might be something we consider in the future.
Got it!
pkg/server/admin.go, line 1222 at r2 (raw file): Previously, koorosh (Andrii Vorobiov) wrote…
Good call out though. I'm glad we all had the same thought. 😄 |
Events in DB Console (`/#/events`) would show an internal server error to the user if they did not have admin permissions to view events. The error logged in the server is indeed a permissions error, but this is confusing to the user. To accurately show a permission error on the FrontEnd, I added an AND statment to the Events endpoint to only return a server error if an error exists and is not a permission error. Release note (ui change): Node events will now display a permission error rather than an internal server error when user does not have admin priviledges to view events.
bors r+ |
Build succeeded: |
Encountered an error creating backports. Some common things that can go wrong:
You might need to create your backport manually using the backport tool. error creating merge commit from f085778 to blathers/backport-release-20.2-72416: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict [] you may need to manually resolve merge conflicts with the backport tool. Backport to branch 20.2.x failed. See errors above. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan. |
blathers backport 21.2 |
Events in DB Console (
/#/events
) would show an internal server errorto the user if they did not have admin permissions to view events. The
error logged in the server is indeed a permissions error, but this is
confusing to the user. To accurately show a permission error on the
FrontEnd, I added an AND statement to the Events endpoint to only return
a server error if an error exists and is not a permission error.
Release note (ui change): Node events will now display a permission
error rather than an internal server error when user does not have admin
privileges to view events.