Skip to content

Commit

Permalink
Remove CORS middleware
Browse files Browse the repository at this point in the history
The AuthService used a CORS middleware as a remnant of the original
fork:
ajmyyra/ambassador-auth-oidc@43dd5ae

The CORS middleware permits requests with certain default methods and
headers. However, since the default answer is 200, what it actually does
is proxy the CORS requests for those methods. I don't like the fact that we
don't set the response code explicitly. We should either remove this middleware
or document its use clearly.

Cherry-pick from: arrikto#58
  • Loading branch information
jfrabaute authored and ajhfok committed Jul 12, 2023
1 parent 52e1136 commit 1ecd808
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/arrikto/oidc-authservice/authorizer"
"github.com/arrikto/oidc-authservice/common"
"github.com/arrikto/oidc-authservice/sessions"
"github.com/gorilla/handlers"

"github.com/gorilla/mux"
"github.com/patrickmn/go-cache"
"github.com/tevino/abool"
Expand Down Expand Up @@ -76,7 +76,7 @@ func main() {
log.Infof("Starting judge server at %v:%v", c.Hostname, c.Port)
stopCh := make(chan struct{})
go func(stopCh chan struct{}) {
log.Fatal(http.ListenAndServe(fmt.Sprintf("%s:%d", c.Hostname, c.Port), handlers.CORS()(router)))
log.Fatal(http.ListenAndServe(fmt.Sprintf("%s:%d", c.Hostname, c.Port), router))
close(stopCh)
}(stopCh)

Expand Down
5 changes: 2 additions & 3 deletions web_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"strings"

"github.com/arrikto/oidc-authservice/common"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
)

Expand All @@ -18,7 +17,7 @@ const (
)

var (
ThemesPath = "/site/themes"
ThemesPath = "/site/themes"
)

type WebServer struct {
Expand Down Expand Up @@ -83,7 +82,7 @@ func (s *WebServer) Start(addr string) error {
),
)

return http.ListenAndServe(addr, handlers.CORS()(router))
return http.ListenAndServe(addr, router)
}

// siteHandler returns an http.HandlerFunc that serves a given template
Expand Down

0 comments on commit 1ecd808

Please sign in to comment.