The Cloud Functions (CFs) are primarily designed for executing simple, standalone tasks, not complex applications.
The recommended CF access control method is based on service accounts and IAM. From Runtime service account:
At runtime, Cloud Functions uses the service account
PROJECT_ID@appspot.gserviceaccount.com
, which has the Editor
role on the project. You can change the roles of this service account
to limit or extend the permissions for your running functions.
This access control method is enforced outside of the actual CF execution, so you don't need to worry about authentication in the CF code - you already know it can only be executed using the respective service account credentials.
Yes, it might be possible to use a custom authentication scheme similar to the one(s) use in more complex applications, but it won't be trivial - it's not what CFs were designed for. See the somehow related When to choose App Engine over Cloud Functions?