Skip to content

Commit 4bc24e2

Browse files
committed
require authentication for api-key endpoints
1 parent 38730bb commit 4bc24e2

File tree

2 files changed

+1
-7
lines changed

2 files changed

+1
-7
lines changed

auth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func AuthenticateRequest(r *http.Request) (User, error) {
5353
return authTOTP(apiKey)
5454

5555
case "api-key":
56-
return nil, nil // no authentication required for api-key
56+
return apiKey, nil
5757

5858
default:
5959
return nil, fmt.Errorf("invalid URL: %s", r.URL)

router/middleware.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"log"
66
"net/http"
7-
"strings"
87

98
mfa "github.com/sil-org/serverless-mfa-api-go"
109
)
@@ -14,11 +13,6 @@ import (
1413
// user from storage and attach to context.
1514
func authenticationMiddleware(next http.Handler) http.Handler {
1615
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
17-
if strings.HasPrefix(r.URL.Path, "/api-key") {
18-
next.ServeHTTP(w, r)
19-
return
20-
}
21-
2216
user, err := mfa.AuthenticateRequest(r)
2317
if err != nil {
2418
log.Printf("unable to authenticate request: %s", err)

0 commit comments

Comments
 (0)