safetrustcr / Backend

Supports a decentralized platform for secure and trusted P2P cryptocurrency transactions.
3 stars 13 forks source link

Create Firebase Auth Account and Integrate with Hasura Project #22

Open sotoJ24 opened 6 days ago

sotoJ24 commented 6 days ago

Create Firebase Auth Account and Integrate with Hasura Project

Set up Firebase Authentication and integrate it with our Hasura GraphQL API to handle user authentication.

Problem

We need to:

Solution

1. Firebase Setup

  1. Create new Firebase project:

    • Go to Firebase Console
    • Click "Add project"
    • Name it "SafeTrust-[Environment]" (e.g., SafeTrust-Dev)
  2. Enable Authentication methods:

    • Navigate to Authentication > Sign-in method
    • Enable:
      • [ ] Email/Password
      • [x] Google
      • [ ] Custom Authentication (for Web3 wallet)

Follow this tutorial:

https://hasura.io/learn/graphql/hasura-authentication/integrations/firebase/

Just in the roles section, create the roles mentioned below

3. Hasura Permission Setup

  1. Create roles in Hasura:

    • anonymous: For unauthenticated users
    • user: For authenticated users
    • tenant: For apartment seekers
    • landlord: For property owners
  2. Configure permissions for users table:

    
    -- Select permissions for user role
    {
    "columns": ["id", "email", "last_seen"],
    "filter": {
    "id": { "_eq": "X-Hasura-User-Id" }
    }
    }

Environment Setup

You can use a dummy login page in the frontend or separate to get the JWT token and test it against the current backend.

  1. Test Hasura JWT:
    query TestAuth {
    users {
    id
    email
    }
    }

Given a valid JWT, this account should

Prerequisites

Success Criteria

Security Checklist

Additional Context

This setup will enable:

Jonatan-Chaverri commented 4 days ago

I will like to take care of this issue! My name is Jonatan, I'm from Dojo Coding community! I had used firebase auth in the past so I have experience on this area.

josephchimebuka commented 4 days ago

Hello I am Joseph I am a frontend developer and blockchain developer and I am also an active contributor here on only dust here is my profile https://app.onlydust.com/u/josephchimebuka. This is my first time to contribute to this repo ill appreciate the opportunity to contribute. this is a couple of frontend and blockchain projects i have built https://metacrypt.vercel.app/ https://mattedsgn.com/ May I try this one?

Michaelkingsdev commented 4 days ago

I'd like to take this issue.

Unickhub commented 4 days ago

Can I take this issue?

ShantelPeters commented 4 days ago

Can I take care of this issue?

martinvibes commented 4 days ago

Can I take care of this issue? i'm a frontend dev and a blockchain dev please kindly assign :)

mariocodecr commented 4 days ago

Hii! My name is Mario Araya, I’m a Software Developer with 2+ years of experience. I have worked with backend technologies such as Cairo, Java, and C#, as well as frontend development using React, NextJS, and JavaScript/TypeScript. I’ve made contributions to open-source projects, completed a Starknet Bootcamp, exercises on NodeGuardians, finished Starklings, and participated in multiple hackathons. I’m also a member of the Dojo Coding community here in Costa Rica.

This involves creating a Firebase project, enabling sign-in methods (email/password, Google, Web3 wallet), and configuring Hasura to accept Firebase JWT tokens. Set up roles (anonymous, user, tenant, landlord) in Hasura with role-based access control for different permissions. Test the JWT integration with a dummy login page, ensuring that role-based permissions work correctly. Make sure Firebase and Hasura are properly configured with correct JWT validation and security settings. I have worked on Firebase projects with different clients, so this setup will enhance user management and security in your project.

rvalenciano commented 3 days ago

@Jonatan-Chaverri , feel free to work on this one please :)