Skip to content

Commit aabeeec

Browse files
authored
Disallow CORS for API Secret Keys (#45)
1 parent 793c888 commit aabeeec

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

middleware.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -232,17 +232,15 @@ func Session(cfg Options) func(next http.Handler) http.Handler {
232232

233233
origin := r.Header.Get("Origin")
234234
if origin != "" {
235-
err := proto.ErrSecretKeyCorsDisallowed.WithCausef("project_id: %v", projectID)
236-
237-
slog.ErrorContext(ctx, "CORS disallowed for Secret Key",
235+
slog.ErrorContext(ctx, "CORS disallowed for API Secret Key",
238236
slog.Any("error", err),
239237
slog.String("origin", origin),
240238
slog.Uint64("project_id", projectID),
241239
)
242240

243-
// TODO: Uncomment once we're confident it won't disrupt major customers.
244-
// cfg.ErrHandler(r, w, err)
245-
// return
241+
err := proto.ErrSecretKeyCorsDisallowed.WithCausef("origin: %v, project_id: %v", origin, projectID)
242+
cfg.ErrHandler(r, w, err)
243+
return
246244
}
247245
}
248246

@@ -326,7 +324,7 @@ func AccessControl(acl Config[ACL], cfg Options) func(next http.Handler) http.Ha
326324
}
327325

328326
// PropagateAccessKey propagates the access key from the context to other webrpc packages.
329-
// It expectes the function `WithHTTPRequestHeaders` from the proto package that requires the access key propogation.
327+
// It expects the function `WithHTTPRequestHeaders` from the proto package that requires the access key propogation.
330328
func PropagateAccessKey(headerContextFuncs ...func(context.Context, http.Header) (context.Context, error)) func(next http.Handler) http.Handler {
331329
return func(next http.Handler) http.Handler {
332330
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

0 commit comments

Comments
 (0)