fix: restrict CORS to configured origins (closes #40) #92
No reviewers
Labels
No Label
bug
duplicate
enhancement
help wanted
invalid
merge-ready
merge-ready
needs-checks
needs-checks
needs-rebase
needs-rebase
needs-review
needs-review
needs-rework
needs-rework
notplanned
question
wontfix
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sneak/upaas#92
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix/cors-wildcard"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The CORS middleware used
AllowedOrigins: []string{"*"}withAllowCredentials: false, which prevents cross-origin cookie-based auth. This PR:UPAAS_CORS_ORIGINSenv var (comma-separated origins)AllowCredentials: trueCORSOriginsfield toconfig.ConfigAlso includes gofmt fixes for pre-existing formatting issues.
Test Results (before fix — build failure)
Test Results (after fix)
Lint Results
Note: 7 pre-existing gosec issues in other files remain (not introduced by this PR).
Closes #40
Important security fix — replacing
AllowedOrigins: ["*"]with explicit origin allowlist and enablingAllowCredentials: true. The old config was dangerous (wildcard + credentials is blocked by browsers, but the intent was wrong).The implementation is clean: no origins configured = no CORS headers (strict same-origin). Good.
One note: the PR also includes whitespace/alignment changes across several files (routes.go, models/app.go, deploy.go). These are fine but could have been a separate commit for cleaner history.
LGTM.