mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
* feat: Add tunnel by default If an access URL is not specified, we will always tunnel. This is from community-member feedback who exclaimed that it's confusing having the default for `coder server` display a warning message, and I agree. There is very little (maybe none) in running `coder server` without tunnel and without an access URL, so this seems like overall a much better UX. * Update install.sh Co-authored-by: Ben Potter <ben@coder.com> * Update docs/install/packages.md Co-authored-by: Ben Potter <ben@coder.com> * Fix reset pass test * Fix e2e test Co-authored-by: Ben Potter <ben@coder.com>
41 lines
928 B
Go
41 lines
928 B
Go
package coderd
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"github.com/coder/coder/coderd/httpapi"
|
|
"github.com/coder/coder/codersdk"
|
|
|
|
"cdr.dev/slog"
|
|
)
|
|
|
|
type cspViolation struct {
|
|
Report map[string]interface{} `json:"csp-report"`
|
|
}
|
|
|
|
// logReportCSPViolations will log all reported csp violations.
|
|
func (api *API) logReportCSPViolations(rw http.ResponseWriter, r *http.Request) {
|
|
ctx := r.Context()
|
|
var v cspViolation
|
|
|
|
dec := json.NewDecoder(r.Body)
|
|
err := dec.Decode(&v)
|
|
if err != nil {
|
|
api.Logger.Warn(ctx, "csp violation", slog.Error(err))
|
|
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
|
|
Message: "Failed to read body, invalid json.",
|
|
Detail: err.Error(),
|
|
})
|
|
return
|
|
}
|
|
|
|
fields := make([]slog.Field, 0, len(v.Report))
|
|
for k, v := range v.Report {
|
|
fields = append(fields, slog.F(k, v))
|
|
}
|
|
api.Logger.Debug(ctx, "csp violation", fields...)
|
|
|
|
httpapi.Write(ctx, rw, http.StatusOK, "ok")
|
|
}
|