Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 90a3deb

Browse files
authored
fix(coderd): pass oauth configs to site (coder#8390)
1 parent 9a3d905 commit 90a3deb

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

coderd/coderd.go

+9-8
Original file line numberDiff line numberDiff line change
@@ -299,19 +299,20 @@ func New(options *Options) *API {
299299
},
300300
)
301301

302-
staticHandler := site.New(&site.Options{
303-
BinFS: binFS,
304-
BinHashes: binHashes,
305-
Database: options.Database,
306-
SiteFS: site.FS(),
307-
})
308-
staticHandler.Experiments.Store(&experiments)
309-
310302
oauthConfigs := &httpmw.OAuth2Configs{
311303
Github: options.GithubOAuth2Config,
312304
OIDC: options.OIDCConfig,
313305
}
314306

307+
staticHandler := site.New(&site.Options{
308+
BinFS: binFS,
309+
BinHashes: binHashes,
310+
Database: options.Database,
311+
SiteFS: site.FS(),
312+
OAuth2Configs: oauthConfigs,
313+
})
314+
staticHandler.Experiments.Store(&experiments)
315+
315316
ctx, cancel := context.WithCancel(context.Background())
316317
r := chi.NewRouter()
317318

site/site.go

+11-6
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,11 @@ func init() {
6161
}
6262

6363
type Options struct {
64-
BinFS http.FileSystem
65-
BinHashes map[string]string
66-
Database database.Store
67-
SiteFS fs.FS
64+
BinFS http.FileSystem
65+
BinHashes map[string]string
66+
Database database.Store
67+
SiteFS fs.FS
68+
OAuth2Configs *httpmw.OAuth2Configs
6869
}
6970

7071
func New(opts *Options) *Handler {
@@ -290,8 +291,12 @@ func (h *Handler) renderHTMLWithState(rw http.ResponseWriter, r *http.Request, f
290291
// Cookies are sent when requesting HTML, so we can get the user
291292
// and pre-populate the state for the frontend to reduce requests.
292293
apiKey, actor, _ := httpmw.ExtractAPIKey(rw, r, httpmw.ExtractAPIKeyConfig{
293-
Optional: true,
294-
DB: h.opts.Database,
294+
Optional: true,
295+
DB: h.opts.Database,
296+
OAuth2Configs: h.opts.OAuth2Configs,
297+
// Special case for site, we can always disable refresh here because
298+
// the frontend will perform API requests if this fails.
299+
DisableSessionExpiryRefresh: true,
295300
})
296301
if apiKey != nil && actor != nil {
297302
ctx := dbauthz.As(r.Context(), actor.Actor)

0 commit comments

Comments
 (0)