Skip to content

sdil/hasura-firebase-auth-webhook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hasura Firebase Auth Webhook

Go Docker

This project is highly inspired by Hasura NodeJS auth webhook boilerplate.

This webhook will verify the token.

Table of Contents

How Hasura authentication works

Generally, Hasura has 3 modes to authenticate users:

  • Webhook*
  • JWT (JSON Web Token)
  • Unauthenticated / Public Access

You can see more how it works here.

This Firebase Auth is intended to work with Webhook

Webhook

How Hasura Firebase Auth webhook helps

If the user is successfully authenticated, the webhook will return the following result to the Hasura server:

$ curl -i localhost:8081 -H "Authorization: Bearer <Firebase token>"

HTTP 200 OK
Content-Type: application/json
Cache-Control: 300
{
    "X-Hasura-User-Id": <Firebase UID>,
    "X-Hasura-Role":    "user",
}

Installation

Host Installation

  1. Download and launch the webhook server

    $ export GOOGLE_APPLICATION_CREDENTIALS="<path to service-account.json file>"
    $ curl -o <file to download> | sh
  2. Start the Hasura GraphQL engine and point the authentication webhook to the hasura-firebase-auth webhook server

    graphql-engine --database-url <DB URL> serve --admin-secret <ADMIN_SECRET_KEY> --auth-hook localhost:8081

Docker-compose environment

  1. Launch the webhook container:

    $ curl https://raw.githubusercontent.com/sdil/hasura-firebase-auth-webhook/master/example/docker-compose/docker-compose.yaml -o docker-compose.yaml
    $ docker-compose up -d
  2. Test the webhook server

  3. Test the GraphQL operation

Kubernetes

  1. Launch the Kubernetes resources:

    $ kubectl create -f https://raw.githubusercontent.com/sdil/hasura-firebase-auth-webhook/master/example/kubernetes/kubernetes.yaml

Roadmap - v1 Stable Release

  • Write a comprehensive unit tests
  • Perform a benchmark & performance test
  • Handle exceptions
  • Add Kubernetes manifest example
  • Write manifests for Kubernetes and Heroku deployment script to ease the adoption
  • Cache the request so that it doesn't stress Firebase auth too much
  • Query Hasura (with admin secret) to get the user's role from database

FAQ

I got this error ....

You're not mounting the service-account.json file in the container.

About

A simple web service for Hasura authentication with Firebase

Resources

License

Stars

2 stars

Watchers

1 watching

Forks

Packages

 
 
 

Contributors