firebase-auth-service

module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2021 License: MIT

README

Grpc-service for Firebase JWTs authentication

Go

Grpc-service for verification and authentication of Firebase JWTs

Usage

  1. Integrate auth interceptors into your grpc-project:
package main

import (
  "net"
  "google.golang.org/grpc"
  auth "github.com/isqad/firebase-auth-service/pkg/service"
)

type UsersAPIServer struct {
	UnimplementedUsersServer
}

func NewUsersAPIServer() (*UsersAPIServer, error) {
  return &UsersAPIServer{}
}

func (s *UsersAPIServer) Start() error {
  authAddr := os.Getenv("FIREBASE_AUTH_SERVICE_ADDRESS")

  l, err := net.Listen("tcp", authAddr)
	if err != nil {
		return err
	}

  a := auth.NewAuthInterceptor(authAddr)

	g := grpc.NewServer(
		grpc.UnaryInterceptor(a.AuthUnaryInterceptor),
    grpc.StreamInterceptor(a.AuthStreamInterceptor),
	)
	RegisterUsersServer(g, s)
	if err := g.Serve(l); err != nil {
		return err
	}

	return nil
}
  1. Build and run the service:
docker build -t your-name:firebase-auth-service:0.1.0 .
docker run --rm -d -p 50053:50053 --name firebase-auth-service your-name:firebase-auth-service your-name:firebase-auth-service:0.1.0
  1. Run your grpc-service.

Roadmap

  • Grabing google pub keys
  • Verification firebase auth JWT of User and extract his ID
  • grpc auth interceptors for services
  • Configuration
  • Tests
  • grpc error codes

Directories

Path Synopsis
cmd
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL