@@ -90,6 +90,7 @@ func New(apiService Service, FSS fs.FS, HFS http.FileSystem) *Service {
90
90
91
91
a .Router = mux .NewRouter ()
92
92
a .Router .Use (a .panicRecovery )
93
+ a .Router .Use (otelmux .Middleware ("thunderdome" ))
93
94
94
95
if apiService .Config .PathPrefix != "" {
95
96
a .Router = a .Router .PathPrefix (apiService .Config .PathPrefix ).Subrouter ()
@@ -104,9 +105,7 @@ func New(apiService Service, FSS fs.FS, HFS http.FileSystem) *Service {
104
105
}
105
106
106
107
router := a .Router .PathPrefix ("/" ).Subrouter ()
107
- a .Router = router
108
108
router .Use (secureMiddleware .Handler )
109
- router .Use (otelmux .Middleware ("thunderdome" ))
110
109
111
110
pokerSvc := poker .New (poker.Config {
112
111
WriteWaitSec : a .Config .WebsocketConfig .WriteWaitSec ,
@@ -517,7 +516,9 @@ func New(apiService Service, FSS fs.FS, HFS http.FileSystem) *Service {
517
516
router .PathPrefix ("/webhooks/subscriptions" ).Handler (a .SubscriptionSvc .HandleWebhook ()).Methods ("POST" )
518
517
}
519
518
520
- a .registerOauthProviderEndpoints (authProviderConfigs )
519
+ // have to pass router because of wonkyness with gorilla/mux and subrouters and middleware to support the Swagger UI and OIDC
520
+ // @todo - refactor router to get away from gorilla/mux
521
+ a .registerOauthProviderEndpoints (router , authProviderConfigs )
521
522
522
523
// static assets
523
524
router .PathPrefix ("/static/" ).Handler (http .StripPrefix (a .Config .PathPrefix , staticHandler ))
@@ -532,7 +533,7 @@ func New(apiService Service, FSS fs.FS, HFS http.FileSystem) *Service {
532
533
return a
533
534
}
534
535
535
- func (s * Service ) registerOauthProviderEndpoints (providers []thunderdome.AuthProviderConfig ) {
536
+ func (s * Service ) registerOauthProviderEndpoints (router * mux. Router , providers []thunderdome.AuthProviderConfig ) {
536
537
ctx := context .Background ()
537
538
var redirectBaseURL string
538
539
var port string
@@ -550,8 +551,9 @@ func (s *Service) registerOauthProviderEndpoints(providers []thunderdome.AuthPro
550
551
551
552
for _ , c := range providers {
552
553
providerNameUrlPath := strings .ToLower (c .ProviderName )
553
- oauthLoginPathPrefix , _ := url .JoinPath ("/oauth/" , providerNameUrlPath , "/login" )
554
- oauthCallbackPathPrefix , _ := url .JoinPath ("/oauth/" , providerNameUrlPath , "/callback" )
554
+ oauthPathPrefix := "/oauth/"
555
+ oauthLoginPathPrefix , _ := url .JoinPath (oauthPathPrefix , providerNameUrlPath , "/login" )
556
+ oauthCallbackPathPrefix , _ := url .JoinPath (oauthPathPrefix , providerNameUrlPath , "/callback" )
555
557
callbackRedirectURL , _ := url .JoinPath (redirectBaseURL , oauthCallbackPathPrefix )
556
558
authProvider , err := oauth .New (oauth.Config {
557
559
AuthProviderConfig : c ,
@@ -562,8 +564,8 @@ func (s *Service) registerOauthProviderEndpoints(providers []thunderdome.AuthPro
562
564
if err != nil {
563
565
panic (err )
564
566
}
565
- s . Router .HandleFunc (oauthLoginPathPrefix , authProvider .HandleOAuth2Redirect ()).Methods ("GET" )
566
- s . Router .HandleFunc (oauthCallbackPathPrefix , authProvider .HandleOAuth2Callback ()).Methods ("GET" )
567
+ router .HandleFunc (oauthLoginPathPrefix , authProvider .HandleOAuth2Redirect ()).Methods ("GET" )
568
+ router .HandleFunc (oauthCallbackPathPrefix , authProvider .HandleOAuth2Callback ()).Methods ("GET" )
567
569
}
568
570
}
569
571
0 commit comments