fix: Redirect to login when unauthenticated and requesting a workspace app (#2903)

Fixes #2884.
This commit is contained in:
Kyle Carberry
2022-07-11 13:46:01 -05:00
committed by GitHub
parent 08d90f7b4f
commit 2c89e07e12
12 changed files with 94 additions and 46 deletions

View File

@ -67,7 +67,7 @@ func TestOrganizationParam(t *testing.T) {
rtr = chi.NewRouter()
)
rtr.Use(
httpmw.ExtractAPIKey(db, nil),
httpmw.ExtractAPIKey(db, nil, false),
httpmw.ExtractOrganizationParam(db),
)
rtr.Get("/", nil)
@ -87,7 +87,7 @@ func TestOrganizationParam(t *testing.T) {
)
chi.RouteContext(r.Context()).URLParams.Add("organization", uuid.NewString())
rtr.Use(
httpmw.ExtractAPIKey(db, nil),
httpmw.ExtractAPIKey(db, nil, false),
httpmw.ExtractOrganizationParam(db),
)
rtr.Get("/", nil)
@ -107,7 +107,7 @@ func TestOrganizationParam(t *testing.T) {
)
chi.RouteContext(r.Context()).URLParams.Add("organization", "not-a-uuid")
rtr.Use(
httpmw.ExtractAPIKey(db, nil),
httpmw.ExtractAPIKey(db, nil, false),
httpmw.ExtractOrganizationParam(db),
)
rtr.Get("/", nil)
@ -135,7 +135,7 @@ func TestOrganizationParam(t *testing.T) {
chi.RouteContext(r.Context()).URLParams.Add("organization", organization.ID.String())
chi.RouteContext(r.Context()).URLParams.Add("user", u.ID.String())
rtr.Use(
httpmw.ExtractAPIKey(db, nil),
httpmw.ExtractAPIKey(db, nil, false),
httpmw.ExtractUserParam(db),
httpmw.ExtractOrganizationParam(db),
httpmw.ExtractOrganizationMemberParam(db),
@ -172,7 +172,7 @@ func TestOrganizationParam(t *testing.T) {
chi.RouteContext(r.Context()).URLParams.Add("organization", organization.ID.String())
chi.RouteContext(r.Context()).URLParams.Add("user", user.ID.String())
rtr.Use(
httpmw.ExtractAPIKey(db, nil),
httpmw.ExtractAPIKey(db, nil, false),
httpmw.ExtractOrganizationParam(db),
httpmw.ExtractUserParam(db),
httpmw.ExtractOrganizationMemberParam(db),