I was playing around with Firebase Cloud Messaging and trying to send a notification to my app through a POST request. I sent a request to https://fcm.googleapis.com/fcm/send
with the following headers:
Authorization: key=<MY-WEB-API-KEY>
Content-Type: application/json
and my message body.
It works, and that is the problem. How come this isn't a security risk? Anyone that goes into my website and looks at the source can get my web API key and send notifications to any users they wish. The only thing I can think of is that without the FCM tokens they won't be able to send messages to anyone, but then they could send messages to a topic which people are subscribed to...
I also thought I might be doing something wrong by putting this API key in my web app, but it says in the Firebase console I should do so.
So what do I do? Am I doing something wrong here?
EDIT: I made the request with Postman, this is the request it generated:
POST /fcm/send HTTP/1.1
Host: fcm.googleapis.com
Authorization: key=AIza.....vI
Content-Type: application/json
cache-control: no-cache
Postman-Token: 4dd619e9-5852-4cb5-ba64-61be77478736
{
"registration_ids":["<device-token>"],
"notification": {
"title":"Title of your notification",
"body":"content of your notification"
},
}------WebKitFormBoundary7MA4YWxkTrZu0gW--
The key in the authorization header is the one I got from my web app configuration section at https://console.firebase.google.com/project/PROJECT-NAME/settings/general/