Skip to content

feature: gate audit log by permissions #3464

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
Aug 11, 2022

Conversation

Kira-Pilot
Copy link
Member

resolves #3460

Only admin and auditor roles should have access to the new audit log. This PR gates both the link in the nav bar as well as the route itself in case someone navigates directly.

@Kira-Pilot Kira-Pilot requested a review from a team as a code owner August 10, 2022 20:19
export const AppRouter: FC = () => {
const xServices = useContext(XServiceContext)
const [authState] = useActor(xServices.authXService)
const { permissions } = authState.context
Copy link
Contributor

@presleyp presleyp Aug 10, 2022

Choose a reason for hiding this comment

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

This is probably a good place to use useSelector instead of useActor so that we don't get re-renders for anything except permissions. In fact, I think my plan was to do that within a wrapper component so that it only gets accessed on pages that need it - see RequireLicense here https://github.com/coder/coder/pull/3008/files#diff-8b4f166561cf1e9c08183827ef490e7741d6e79022122df7d835292bc3b3d0e7

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm realizing now that I was thinking about licensing instead of role-based permissions, but maybe it's still a good idea? Up to you!

Copy link
Member Author

Choose a reason for hiding this comment

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

That is a good idea! I will play around with the wrapper component when I get to licensing, and make sure permissions go in there, too, if possible.

@Kira-Pilot Kira-Pilot requested review from Emyrk and coadler August 10, 2022 20:45
Copy link
Member

@Emyrk Emyrk left a comment

Choose a reason for hiding this comment

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

The perm stuff looks good 👍. I'll flush out the perms for audit_log when the feature gets in.

Copy link
Contributor

@presleyp presleyp left a comment

Choose a reason for hiding this comment

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

With the switch from useActor to useSelector, should be good!

@Kira-Pilot Kira-Pilot merged commit 6122df6 into main Aug 11, 2022
@Kira-Pilot Kira-Pilot deleted the audit-log-permissions/kira-pilot branch August 11, 2022 13:34
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.

Gate audit log by permissions
3 participants