Skip to content

Commit 2a61e73

Browse files
committed
only allow me on users
1 parent b67e7e7 commit 2a61e73

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

coderd/httpmw/httpmw.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func parseUUID(rw http.ResponseWriter, r *http.Request, param string) (uuid.UUID
2121
}
2222

2323
// Automatically set uuid.Nil to the acting users id.
24-
if rawID == "me" {
24+
if param == UserKey && rawID == "me" {
2525
key := APIKey(r)
2626
return key.UserID, true
2727
}

coderd/httpmw/userparam.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"github.com/coder/coder/coderd/httpapi"
1010
)
1111

12+
const UserKey = "user"
13+
1214
type userParamContextKey struct{}
1315

1416
// UserParam returns the user from the ExtractUserParam handler.
@@ -24,7 +26,7 @@ func UserParam(r *http.Request) database.User {
2426
func ExtractUserParam(db database.Store) func(http.Handler) http.Handler {
2527
return func(next http.Handler) http.Handler {
2628
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
27-
userID, ok := parseUUID(rw, r, "user")
29+
userID, ok := parseUUID(rw, r, UserKey)
2830
if !ok {
2931
return
3032
}

0 commit comments

Comments
 (0)