Skip to content

feat!: drop reading other 'user' permission #8650

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 16 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Hide /users page for regular users
  • Loading branch information
Emyrk committed Jul 25, 2023
commit 4545d1a6ee770168504b84ff6430e7df7ea8038c
2 changes: 0 additions & 2 deletions coderd/rbac/roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,6 @@ func ReloadBuiltinRoles(opts *RoleOptions) {
Name: member,
DisplayName: "",
Site: Permissions(map[string][]Action{
// All users can read all other users and know they exist.
ResourceUser.Type: {ActionRead},
ResourceRoleAssignment.Type: {ActionRead},
// All users can see the provisioner daemons.
ResourceProvisionerDaemon.Type: {ActionRead},
Expand Down
2 changes: 2 additions & 0 deletions site/src/components/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const Navbar: FC = () => {
const canViewAuditLog =
featureVisibility["audit_log"] && Boolean(permissions.viewAuditLog)
const canViewDeployment = Boolean(permissions.viewDeploymentValues)
const canViewAllUsers = Boolean(permissions.readAllUsers)
const onSignOut = () => authSend("SIGN_OUT")
const proxyContextValue = useProxy()
const dashboard = useDashboard()
Expand All @@ -29,6 +30,7 @@ export const Navbar: FC = () => {
onSignOut={onSignOut}
canViewAuditLog={canViewAuditLog}
canViewDeployment={canViewDeployment}
canViewAllUsers={canViewAllUsers}
proxyContextValue={
dashboard.experiments.includes("moons") ? proxyContextValue : undefined
}
Expand Down
8 changes: 8 additions & 0 deletions site/src/components/Navbar/NavbarView.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ describe("NavbarView", () => {
onSignOut={noop}
canViewAuditLog
canViewDeployment
canViewAllUsers
/>,
)
const workspacesLink = await screen.findByText(navLanguage.workspaces)
Expand All @@ -62,6 +63,7 @@ describe("NavbarView", () => {
onSignOut={noop}
canViewAuditLog
canViewDeployment
canViewAllUsers
/>,
)
const templatesLink = await screen.findByText(navLanguage.templates)
Expand All @@ -76,6 +78,7 @@ describe("NavbarView", () => {
onSignOut={noop}
canViewAuditLog
canViewDeployment
canViewAllUsers
/>,
)
const userLink = await screen.findByText(navLanguage.users)
Expand All @@ -98,6 +101,7 @@ describe("NavbarView", () => {
onSignOut={noop}
canViewAuditLog
canViewDeployment
canViewAllUsers
/>,
)

Expand All @@ -115,6 +119,7 @@ describe("NavbarView", () => {
onSignOut={noop}
canViewAuditLog
canViewDeployment
canViewAllUsers
/>,
)
const auditLink = await screen.findByText(navLanguage.audit)
Expand All @@ -129,6 +134,7 @@ describe("NavbarView", () => {
onSignOut={noop}
canViewAuditLog={false}
canViewDeployment
canViewAllUsers
/>,
)
const auditLink = screen.queryByText(navLanguage.audit)
Expand All @@ -143,6 +149,7 @@ describe("NavbarView", () => {
onSignOut={noop}
canViewAuditLog
canViewDeployment
canViewAllUsers
/>,
)
const auditLink = await screen.findByText(navLanguage.deployment)
Expand All @@ -159,6 +166,7 @@ describe("NavbarView", () => {
onSignOut={noop}
canViewAuditLog={false}
canViewDeployment={false}
canViewAllUsers
/>,
)
const auditLink = screen.queryByText(navLanguage.deployment)
Expand Down
19 changes: 13 additions & 6 deletions site/src/components/Navbar/NavbarView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface NavbarViewProps {
onSignOut: () => void
canViewAuditLog: boolean
canViewDeployment: boolean
canViewAllUsers: boolean
proxyContextValue?: ProxyContextValue
}

Expand All @@ -52,8 +53,9 @@ const NavItems: React.FC<
className?: string
canViewAuditLog: boolean
canViewDeployment: boolean
canViewAllUsers: boolean
}>
> = ({ className, canViewAuditLog, canViewDeployment }) => {
> = ({ className, canViewAuditLog, canViewDeployment, canViewAllUsers }) => {
const styles = useStyles()
const location = useLocation()

Expand All @@ -75,11 +77,13 @@ const NavItems: React.FC<
{Language.templates}
</NavLink>
</ListItem>
<ListItem button className={styles.item}>
<NavLink className={styles.link} to={USERS_LINK}>
{Language.users}
</NavLink>
</ListItem>
{canViewAllUsers && (
<ListItem button className={styles.item}>
<NavLink className={styles.link} to={USERS_LINK}>
{Language.users}
</NavLink>
</ListItem>
)}
{canViewAuditLog && (
<ListItem button className={styles.item}>
<NavLink className={styles.link} to="/audit">
Expand All @@ -105,6 +109,7 @@ export const NavbarView: FC<NavbarViewProps> = ({
onSignOut,
canViewAuditLog,
canViewDeployment,
canViewAllUsers,
proxyContextValue,
}) => {
const styles = useStyles()
Expand Down Expand Up @@ -142,6 +147,7 @@ export const NavbarView: FC<NavbarViewProps> = ({
<NavItems
canViewAuditLog={canViewAuditLog}
canViewDeployment={canViewDeployment}
canViewAllUsers={canViewAllUsers}
/>
</div>
</Drawer>
Expand All @@ -158,6 +164,7 @@ export const NavbarView: FC<NavbarViewProps> = ({
className={styles.desktopNavItems}
canViewAuditLog={canViewAuditLog}
canViewDeployment={canViewDeployment}
canViewAllUsers={canViewAllUsers}
/>

<Box
Expand Down