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

@ -103,10 +103,10 @@ func New(options *Options) *API {
siteHandler: site.Handler(site.FS(), binFS),
}
api.workspaceAgentCache = wsconncache.New(api.dialWorkspaceAgent, 0)
apiKeyMiddleware := httpmw.ExtractAPIKey(options.Database, &httpmw.OAuth2Configs{
oauthConfigs := &httpmw.OAuth2Configs{
Github: options.GithubOAuth2Config,
})
}
apiKeyMiddleware := httpmw.ExtractAPIKey(options.Database, oauthConfigs, false)
r.Use(
func(next http.Handler) http.Handler {
@ -121,7 +121,7 @@ func New(options *Options) *API {
apps := func(r chi.Router) {
r.Use(
httpmw.RateLimitPerMinute(options.APIRateLimit),
apiKeyMiddleware,
httpmw.ExtractAPIKey(options.Database, oauthConfigs, true),
httpmw.ExtractUserParam(api.Database),
)
r.HandleFunc("/*", api.workspaceAppsProxyPath)