Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 2.1.2 - remove CORS middleware #62

Merged
merged 2 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions server/cors_middleware.go

This file was deleted.

13 changes: 3 additions & 10 deletions server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ import (
mfa "github.com/silinternational/serverless-mfa-api-go"
)

var (
envConfig mfa.EnvConfig
)
var envConfig mfa.EnvConfig

func main() {
log.SetOutput(os.Stdout)
Expand All @@ -31,7 +29,7 @@ func main() {
// ListenAndServe starts an HTTP server with a given address and
// handler defined in NewRouter.
log.Println("Starting service on port 8080")
router := newRouter([]mux.MiddlewareFunc{corsMiddleware})
router := newRouter()
log.Fatal(http.ListenAndServe(":8080", router))
}

Expand Down Expand Up @@ -88,15 +86,10 @@ var routes = []route{
}

// newRouter forms a new mux router, see https://github.com/gorilla/mux.
func newRouter(mws []mux.MiddlewareFunc) *mux.Router {
func newRouter() *mux.Router {
// Create a basic router.
router := mux.NewRouter().StrictSlash(true)

// attach any extra middleware
for _, mw := range mws {
router.Use(mw)
}

// authenticate request based on api key and secret in headers
// also adds user to context
router.Use(authenticationMiddleware)
Expand Down
8 changes: 3 additions & 5 deletions u2fserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ import (
u2fsim "github.com/silinternational/serverless-mfa-api-go/u2fsimulator"
)

var (
envConfig mfa.EnvConfig
)
var envConfig mfa.EnvConfig

func main() {
log.SetOutput(os.Stdout)
Expand All @@ -23,7 +21,7 @@ func main() {
// ListenAndServe starts an HTTP server with a given address and
// handler defined in NewRouter.
log.Println("Starting service on port 8080")
router := newRouter(nil)
router := newRouter()
log.Fatal(http.ListenAndServe(":8080", router))
}

Expand All @@ -47,7 +45,7 @@ var routes = []route{
}

// newRouter forms a new mux router, see https://github.com/gorilla/mux.
func newRouter(mws []mux.MiddlewareFunc) *mux.Router {
func newRouter() *mux.Router {
// Create a basic router.
router := mux.NewRouter().StrictSlash(true)

Expand Down