Skip to content

Commit

Permalink
fix(api): disallow db and rssfeed recipient types in /api/notifier
Browse files Browse the repository at this point in the history
  • Loading branch information
JM-Lemmi committed Sep 24, 2024
1 parent 3c480c6 commit 56f20b8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 2.0.0-beta.9.1

- disallow db and rssfeed recipient types in /api/notifier/

# 2.0.0-beta.9

- ical-notifier binary hived off
Expand Down
9 changes: 9 additions & 0 deletions cmd/ical-relay/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,14 @@ func NotifyRecipientApiHandler(w http.ResponseWriter, r *http.Request) {
// get URL parameters
rectype := r.URL.Query().Get("type")
recipient := r.URL.Query().Get("recipient")

if rectype != "mail" && rectype != "webhook" {
// denying access to other recipient types, like db and rss feed
w.WriteHeader(http.StatusForbidden)
fmt.Fprint(w, "Access denied\n")
return
}

if rectype == "mail" {
// check for valid email address on mail recipient type
if !helpers.ValidMail(recipient) {
Expand All @@ -211,6 +219,7 @@ func NotifyRecipientApiHandler(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
fmt.Fprint(w, "Added "+rectype+" "+recipient+" to "+notifier+"\n")
}

case http.MethodDelete:
err := dataStore.RemoveNotifyRecipient(notifier, datastore.Recipient{Recipient: recipient, Type: rectype})
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions documentation/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ paths:
description: successful operation
'400':
description: not a valid type or E-Mail address
'403':
description: disallowed recipient type
'404':
description: Notifier does not exist
'500':
Expand Down

0 comments on commit 56f20b8

Please sign in to comment.