I have a function that I want to run via HTTP call in a simple script tag, i.e. <script src="https://server-location.cloudfunctions.net/function-name />
. I want to make sure that the calls only come from a whitelisted domain, like you can do with cloud storage access requests, for example.
I've seen a couple of suggestions on SO (1 2 3), but they all suggest either a) IAM credentials in the request headers or b) including some security checks in the function itself. These won't work because a) you can't send headers with a script
tag and, even if you could, I'd have to store the credentials in the html which is not secure, and b) security checks in the function will not limit the number of calls made to the function, and that's what I want to do (to prevent a horrendous bill).
Is there a way to do this?