Skip to content
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: proper error handling in sessions API #78176

Merged
merged 1 commit into from
Mar 21, 2022

Conversation

xinhaoz
Copy link
Member

@xinhaoz xinhaoz commented Mar 21, 2022

Fixes #76288

Previously, part of the code in the sessions API that handles
privelege checking would swallow non-privelege related server
errors. The function
requireViewActivityOrViewActivityRedactedPermission
was being used to check if the user has either of the above
roles. This function returns an error as a single value, which
can be either a privelege or non-privelege related error.
It is intended for use when either role is required to use the API,
with the error returned immediately, however the sessions API is
should work for users without these permissions if given the
correct request parameters.

This commit replaces the use of
requireViewActivityOrViewActivityRedactedPermission with
hasRoleOption to check for the possession of the VIEWACTIVITY
or VIEWACTIVITYREDACTED roles. This allows us to use both the
result of the role check and return errors encountered immediately.

Release note: None

@xinhaoz xinhaoz requested a review from a team March 21, 2022 15:25
@xinhaoz xinhaoz requested a review from a team as a code owner March 21, 2022 15:25
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

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

thank you! Please make sure this is backported too.

Copy link
Contributor

@maryliag maryliag left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained

Fixes cockroachdb#76288

Previously, part of the code in the sessions API that handles
privelege checking would swallow non-privelege related server
errors. The function
`requireViewActivityOrViewActivityRedactedPermission`
was being used to check if the user has either of the above
roles. This function returns an error as a single value, which
can be either a  privelege or non-privelege related error.
It is intended for use when either role is required to use the API,
with the error returned immediately, however the sessions API is
should work for users without these permissions if given the
correct request parameters.

This commit replaces the use of
`requireViewActivityOrViewActivityRedactedPermission` with
`hasRoleOption` to check for the possession of the VIEWACTIVITY
or VIEWACTIVITYREDACTED roles. This allows us to use both the
result of the role check and return errors encountered immediately.

Release justification: bug fix

Release note: None
@xinhaoz xinhaoz force-pushed the sessions-error-handling branch from 6a32a21 to 3c0aaa1 Compare March 21, 2022 17:20
@xinhaoz
Copy link
Member Author

xinhaoz commented Mar 21, 2022

TFTR! + thanks for adding the backport label, Marylia.
bors r+

@craig
Copy link
Contributor

craig bot commented Mar 21, 2022

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Mar 21, 2022

Build succeeded:

@craig craig bot merged commit 6dde759 into cockroachdb:master Mar 21, 2022
@xinhaoz xinhaoz deleted the sessions-error-handling branch March 23, 2022 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

server: error checking in session API is incorrect
4 participants