diff --git a/coderd/coderd.go b/coderd/coderd.go index 9d2045b9ca2da..b02b3e0e2d1cf 100644 --- a/coderd/coderd.go +++ b/coderd/coderd.go @@ -299,19 +299,20 @@ func New(options *Options) *API { }, ) - staticHandler := site.New(&site.Options{ - BinFS: binFS, - BinHashes: binHashes, - Database: options.Database, - SiteFS: site.FS(), - }) - staticHandler.Experiments.Store(&experiments) - oauthConfigs := &httpmw.OAuth2Configs{ Github: options.GithubOAuth2Config, OIDC: options.OIDCConfig, } + staticHandler := site.New(&site.Options{ + BinFS: binFS, + BinHashes: binHashes, + Database: options.Database, + SiteFS: site.FS(), + OAuth2Configs: oauthConfigs, + }) + staticHandler.Experiments.Store(&experiments) + ctx, cancel := context.WithCancel(context.Background()) r := chi.NewRouter() diff --git a/site/site.go b/site/site.go index a358d458e561a..98ec8000fb761 100644 --- a/site/site.go +++ b/site/site.go @@ -61,10 +61,11 @@ func init() { } type Options struct { - BinFS http.FileSystem - BinHashes map[string]string - Database database.Store - SiteFS fs.FS + BinFS http.FileSystem + BinHashes map[string]string + Database database.Store + SiteFS fs.FS + OAuth2Configs *httpmw.OAuth2Configs } func New(opts *Options) *Handler { @@ -290,8 +291,12 @@ func (h *Handler) renderHTMLWithState(rw http.ResponseWriter, r *http.Request, f // Cookies are sent when requesting HTML, so we can get the user // and pre-populate the state for the frontend to reduce requests. apiKey, actor, _ := httpmw.ExtractAPIKey(rw, r, httpmw.ExtractAPIKeyConfig{ - Optional: true, - DB: h.opts.Database, + Optional: true, + DB: h.opts.Database, + OAuth2Configs: h.opts.OAuth2Configs, + // Special case for site, we can always disable refresh here because + // the frontend will perform API requests if this fails. + DisableSessionExpiryRefresh: true, }) if apiKey != nil && actor != nil { ctx := dbauthz.As(r.Context(), actor.Actor)