Skip to content

Commit 9b1ef29

Browse files
authored
fix: Allow fetching of non-personal workspaces (coder#1495)
RBAC should cover this anyways!
1 parent 1ed69b9 commit 9b1ef29

File tree

2 files changed

+0
-33
lines changed

2 files changed

+0
-33
lines changed

coderd/httpmw/workspaceparam.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,6 @@ func ExtractWorkspaceParam(db database.Store) func(http.Handler) http.Handler {
4444
return
4545
}
4646

47-
apiKey := APIKey(r)
48-
if apiKey.UserID != workspace.OwnerID {
49-
httpapi.Write(rw, http.StatusUnauthorized, httpapi.Response{
50-
Message: "getting non-personal workspaces isn't supported",
51-
})
52-
return
53-
}
54-
5547
ctx := context.WithValue(r.Context(), workspaceParamContextKey{}, workspace)
5648
next.ServeHTTP(rw, r.WithContext(ctx))
5749
})

coderd/httpmw/workspaceparam_test.go

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -92,31 +92,6 @@ func TestWorkspaceParam(t *testing.T) {
9292
require.Equal(t, http.StatusNotFound, res.StatusCode)
9393
})
9494

95-
t.Run("NonPersonal", func(t *testing.T) {
96-
t.Parallel()
97-
db := databasefake.New()
98-
rtr := chi.NewRouter()
99-
rtr.Use(
100-
httpmw.ExtractAPIKey(db, nil),
101-
httpmw.ExtractWorkspaceParam(db),
102-
)
103-
rtr.Get("/", nil)
104-
r, _ := setup(db)
105-
workspace, err := db.InsertWorkspace(context.Background(), database.InsertWorkspaceParams{
106-
ID: uuid.New(),
107-
OwnerID: uuid.New(),
108-
Name: "hello",
109-
})
110-
require.NoError(t, err)
111-
chi.RouteContext(r.Context()).URLParams.Add("workspace", workspace.ID.String())
112-
rw := httptest.NewRecorder()
113-
rtr.ServeHTTP(rw, r)
114-
115-
res := rw.Result()
116-
defer res.Body.Close()
117-
require.Equal(t, http.StatusUnauthorized, res.StatusCode)
118-
})
119-
12095
t.Run("Found", func(t *testing.T) {
12196
t.Parallel()
12297
db := databasefake.New()

0 commit comments

Comments
 (0)