Skip to content

fix(security)!: path-based app sharing changes #5772

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
Jan 18, 2023
Merged
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
fixup! Merge branch 'main' into dean/path-app-security
  • Loading branch information
deansheather committed Jan 18, 2023
commit 1bb636a51d80de055d1923183a433ab6c7d095fc
26 changes: 13 additions & 13 deletions coderd/workspaceapps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1306,7 +1306,7 @@ func TestAppSharing(t *testing.T) {
}

testLevels := func(t *testing.T, isPathApp, pathAppSharingEnabled, siteOwnerPathAppAccessEnabled bool) {
workspace, agent, user, ownerClient, client, clientInOtherOrg, clientWithNoAuth := setup(t, pathAppSharingEnabled, siteOwnerPathAppAccessEnabled)
workspace, agnt, user, ownerClient, client, clientInOtherOrg, clientWithNoAuth := setup(t, pathAppSharingEnabled, siteOwnerPathAppAccessEnabled)

allowedUnlessSharingDisabled := !isPathApp || pathAppSharingEnabled
siteOwnerCanAccess := !isPathApp || siteOwnerPathAppAccessEnabled
Expand All @@ -1323,51 +1323,51 @@ func TestAppSharing(t *testing.T) {

// Site owner should be able to access all workspaces if
// enabled.
verifyAccess(t, isPathApp, user.Username, workspace.Name, agent.Name, proxyTestAppNameOwner, ownerClient, siteOwnerCanAccess, false)
verifyAccess(t, isPathApp, user.Username, workspace.Name, agnt.Name, proxyTestAppNameOwner, ownerClient, siteOwnerCanAccess, false)

// Owner should be able to access their own workspace.
verifyAccess(t, isPathApp, user.Username, workspace.Name, agent.Name, proxyTestAppNameOwner, client, true, false)
verifyAccess(t, isPathApp, user.Username, workspace.Name, agnt.Name, proxyTestAppNameOwner, client, true, false)

// Authenticated users should not have access to a workspace that
// they do not own.
verifyAccess(t, isPathApp, user.Username, workspace.Name, agent.Name, proxyTestAppNameOwner, clientInOtherOrg, false, false)
verifyAccess(t, isPathApp, user.Username, workspace.Name, agnt.Name, proxyTestAppNameOwner, clientInOtherOrg, false, false)

// Unauthenticated user should not have any access.
verifyAccess(t, isPathApp, user.Username, workspace.Name, agent.Name, proxyTestAppNameOwner, clientWithNoAuth, false, true)
verifyAccess(t, isPathApp, user.Username, workspace.Name, agnt.Name, proxyTestAppNameOwner, clientWithNoAuth, false, true)
})

t.Run("LevelAuthenticated", func(t *testing.T) {
t.Parallel()

// Site owner should be able to access all workspaces if
// enabled.
verifyAccess(t, isPathApp, user.Username, workspace.Name, agent.Name, proxyTestAppNameAuthenticated, ownerClient, siteOwnerCanAccessShared, false)
verifyAccess(t, isPathApp, user.Username, workspace.Name, agnt.Name, proxyTestAppNameAuthenticated, ownerClient, siteOwnerCanAccessShared, false)

// Owner should be able to access their own workspace.
verifyAccess(t, isPathApp, user.Username, workspace.Name, agent.Name, proxyTestAppNameAuthenticated, client, true, false)
verifyAccess(t, isPathApp, user.Username, workspace.Name, agnt.Name, proxyTestAppNameAuthenticated, client, true, false)

// Authenticated users should be able to access the workspace.
verifyAccess(t, isPathApp, user.Username, workspace.Name, agent.Name, proxyTestAppNameAuthenticated, clientInOtherOrg, allowedUnlessSharingDisabled, false)
verifyAccess(t, isPathApp, user.Username, workspace.Name, agnt.Name, proxyTestAppNameAuthenticated, clientInOtherOrg, allowedUnlessSharingDisabled, false)

// Unauthenticated user should not have any access.
verifyAccess(t, isPathApp, user.Username, workspace.Name, agent.Name, proxyTestAppNameAuthenticated, clientWithNoAuth, false, true)
verifyAccess(t, isPathApp, user.Username, workspace.Name, agnt.Name, proxyTestAppNameAuthenticated, clientWithNoAuth, false, true)
})

t.Run("LevelPublic", func(t *testing.T) {
t.Parallel()

// Site owner should be able to access all workspaces if
// enabled.
verifyAccess(t, isPathApp, user.Username, workspace.Name, agent.Name, proxyTestAppNamePublic, ownerClient, siteOwnerCanAccessShared, false)
verifyAccess(t, isPathApp, user.Username, workspace.Name, agnt.Name, proxyTestAppNamePublic, ownerClient, siteOwnerCanAccessShared, false)

// Owner should be able to access their own workspace.
verifyAccess(t, isPathApp, user.Username, workspace.Name, agent.Name, proxyTestAppNamePublic, client, true, false)
verifyAccess(t, isPathApp, user.Username, workspace.Name, agnt.Name, proxyTestAppNamePublic, client, true, false)

// Authenticated users should be able to access the workspace.
verifyAccess(t, isPathApp, user.Username, workspace.Name, agent.Name, proxyTestAppNamePublic, clientInOtherOrg, allowedUnlessSharingDisabled, false)
verifyAccess(t, isPathApp, user.Username, workspace.Name, agnt.Name, proxyTestAppNamePublic, clientInOtherOrg, allowedUnlessSharingDisabled, false)

// Unauthenticated user should be able to access the workspace.
verifyAccess(t, isPathApp, user.Username, workspace.Name, agent.Name, proxyTestAppNamePublic, clientWithNoAuth, allowedUnlessSharingDisabled, !allowedUnlessSharingDisabled)
verifyAccess(t, isPathApp, user.Username, workspace.Name, agnt.Name, proxyTestAppNamePublic, clientWithNoAuth, allowedUnlessSharingDisabled, !allowedUnlessSharingDisabled)
})
}

Expand Down