When creating Callable Firebase Cloud Functions (using onCall) do I need to worry about CSRF attacks?
And if so, how do I protect myself against those attacks?
This is what my callable functions check for so far (App Check, authentication, and agrument):
export const myCallableFunction = functions.https.onCall(
async (myData, context) => {
// Check it passes App Check
if (context.app == undefined) {
throw new functions.https.HttpsError(
'failed-precondition',
'The function must be called from an App Check verified app.'
);
}
// Check the authentication
if (!context.auth) {
throw new functions.https.HttpsError(
'unauthenticated',
'The function must be called while authenticated.'
);
}
// Check the 'myData' argument
if (!(typeof myData === 'string') || myData.length === 0) {
throw new functions.https.HttpsError(
'invalid-argument',
'The myData argument is missing.'
);
}
// Do the operation here
}
);
Do I need to check for something else to protect against CSRF attacks?