fix: force secure response cookies#142
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8784aa4c20
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| func WriteHTTP(writer http.ResponseWriter, result Response) error { | ||
| status := statusOrDefault(result) | ||
| for _, cookie := range result.Cookies { | ||
| cookie.Secure = true |
There was a problem hiding this comment.
Preserve callers' HTTP-development cookie policy
This unconditional overwrite breaks callers that intentionally set Secure: false for local HTTP flows. For example, the login example defaults GOWDK_COOKIE_SECURE to false in examples/login/src/features/auth/auth.go and the documented make serve flow opens http://127.0.0.1:8090/; with this line, response.WithCookie emits a Secure session cookie anyway, so browsers/cookie jars will not send it back over the documented HTTP URL and the login redirect lands without an authenticated session. Please keep the caller's cookie.Secure value or make the secure policy configurable where WriteHTTP is used.
Useful? React with 👍 / 👎.
Set cookies to be secure when writing HTTP responses.
Summary
Secure=trueon cookies written throughruntime/response.WriteHTTP.This addresses the CodeQL alert for
Cookie Secure attribute is not set to trueatruntime/response.WriteHTTP.Verification
scripts/test-go-modules.shwhen Go code or compiler behavior changed.go build ./cmd/gowdkwhen CLI, compiler, runtime, addon, or release behavior changed.node --check editors/vscode/extension.jswhen editor files changed.Additional validation:
go test ./runtime/responsegit diff --checkgo test ./...LLM Assistance