Skip to content

Commit bde71ca

Browse files
committed
auth on test notification endpoint
1 parent ef4f795 commit bde71ca

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

coderd/notifications.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,12 @@ func (api *API) postUserPushNotificationTest(rw http.ResponseWriter, r *http.Req
428428
return
429429
}
430430

431+
// We need to authorize the user to send a push notification to themselves.
432+
if !api.Authorize(r, policy.ActionCreate, rbac.ResourceNotificationMessage.WithOwner(user.ID.String())) {
433+
httpapi.Forbidden(rw)
434+
return
435+
}
436+
431437
if err := api.WebpushDispatcher.Dispatch(ctx, user.ID, codersdk.WebpushMessage{
432438
Title: "It's working!",
433439
Body: "You've subscribed to push notifications.",

0 commit comments

Comments
 (0)