Firebase auth to access Aws DynamoDB - firebase

I've to create a json returning api hosted on aws(aws is must can't use Firebase cloud Functions).
User who have logged in on webapp can only access api.
I've found Serverless Api with Aws Api Gateway + DynamoDB which doesn't use Aws Lambda Functions.
Access can be limited using AWS Cognito which isn't free!
FirebaseAuth is free! . So my question is how do I use firebase auth to limit access to above api?

This article Firebase authentication vs AWS Cognito might be of some help.
You need to set up a custom authorizer:
https://aws.amazon.com/blogs/mobile/integrating-amazon-cognito-user-pools-with-api-gateway/
https://blog.novoda.com/custom-authentication-with-amazon-cognito-and-firebase/

Related

Do I have to enable Firebase if I want to connect to my Cloud Firestore database from outside of Google cloud products?

Till now I was using service account to connect to my Firestore database (Firebase is not enabled) from within Google products like Cloud Functions or Colab.
Now I need to connect to Firestore from html page opened in my browser. Is it possible without enabling Firebase?
Yes, the Google Cloud Firestore NodeJS SDK is meant to be used on server side only. You can use Firebase Web SDK along with Firebase Authentication and Firebase Security Rules to support serverless app architectures where clients connect directly to your Firestore database.
You don't necessarily have to use Firebase Auth. However, it might be a good idea to restrict access and allow only public content to be accessible without authentication.
You can follow the quickstart in the documentation to setup the client SDK.

How to implement signInWithEmailAndPassword method of firebase as cloud function?

I am currently building an app with vue/firebase. But I eventually want to switch to AWS in the future. So I don't want to use the register or sign in method of firebase in my frontend project so that it will be easier to switch to AWS.
How can I implement the same functionality of signInWithEmailAndPassword and createUserWithEmailAndPassword as cloud functions?
Creating users from a Cloud function using Admin SDK (createUser()) is technically same as users signing up using client SDK from your web app since they both create user accounts in Firebase Authentication.
I'm not what you mean by 'switch to AWS', but if that's referring to using any other authentication system e.g. AWS Amplify in this case, then you can just export users from Firebase authentication and then create user accounts in the new auth provider.

Question regarding using both Firebase and REST APIs in application

I have been creating a flutter app and am using firebase for authentication.
Is it possible and best practice to use the firebase only for the authentication and use REST APIs via http package for the CRUD operations instead of using cloud firestore?
Yes, it sure is possible, and common. If you want to send the user credentials to your backend for verification, you should use the Firebase Admin SDK to verify a user ID token.

access google cloud storage with firebase credential

I have a node.js client that uses firebase authentication. Now I want to access Google Cloud Storage, however the firebase SDK for node.js does not include GCS. Using #google-cloud/storage works but only with anonymous access. How do I apply the firebase credential to #google-cloud/storage so that GCS access is in the context of the logged-in user?
Node.js is a server that operates in a privileged environment. The Firebase Admin SDK (aka the Node SDK) talks to other services via a service account.
Firebase Authentication enables client-side authentication. The JavaScript SDK is the client-side SDK.
There is no Node.js client SDK for Firebase that accesses Cloud Storage. Since both the Firebase Admin SDK and the Google Cloud Platform client for Node.js use administrative privileges to access Cloud Storage, it looks like those won't be an option for you either.
The two options I can think of are:
Use the Admin SDK in a Cloud Function, and expose the files from Cloud Storage that way.
Use the REST API for Cloud Storage.
I admit that neither is trivial, so I hope somebody knows a better solution.

generating access token in Cloud Functions for service-service auth

I am trying to establish service-service authentication between Cloud Functions and Cloud Endpoints.
I am trying to send a HTTP request inside a Firebase Cloud Function to my API running on Google App Engine and managed by Google Cloud Endpoints.
As stated in google docs, the service account that Firebase Cloud Functions uses is ____#cloudservices.gserviceaccount.com
I added that issuer in the security definition of my openAPI config(cloud endpoints). However, I could not find a way to create an access token in Cloud Functions of that service account.
How can I generate an access token in Cloud Functions to authenticate itself to Cloud Endpoints? How am I supposed to sign the JWT on cloud functions to request an access token?
Use Application Default Credentials.

Resources