Categorygithub.com/lewiswatson/firebase-jwt-auth
modulepackage
1.0.0
Repository: https://github.com/lewiswatson/firebase-jwt-auth.git
Documentation: pkg.go.dev

# README

Firebase Authentication JWT Verifier

Build Status Coverage Status GoDoc stability-stable

This library follows the instructions described in verify id tokens using third-party JWT library section of the firebase documentation.

Example Usage

import (
	"github.com/LewisWatson/firebase-jwt-auth"
	"github.com/manyminds/api2go"
)

// tokenVerifier previously initialised with fireauth.New("projectname")
func verify(r api2go.Request, tokenVerifier fireauth.TokenVerifier) error {
	token := r.Header.Get("authorization")
	userID, claims, err := tokenVerifier.Verify(token)
	if err != nil {
		return err
	}
	r.Context.Set("userID", userID)
	r.Context.Set("claims", claims)
	return nil
}

# Functions

GetKeys client tokens must be signed by one of the server keys provided via a url.
New creates a new instance of FireAuth with default values and loads the latest keys from the Firebase servers.

# Constants

FirebaseKeyURL Firebase key provider url specified in https://firebase.google.com/docs/auth/admin/verify-id-tokens#verify_id_tokens_using_a_third-party_jwt_library.
HeaderCacheControl Cache-Control field in http response header.
IssPrefix JWT issuer prefix specified in https://firebase.google.com/docs/auth/admin/verify-id-tokens#verify_id_tokens_using_a_third-party_jwt_library.

# Variables

ErrCacheControlHeaderLacksMaxAge indicates that the key server response didnt contain a max age as specified by the firebase docs.
ErrNilToken is returned when the authorization token is empty.
ErrNotIssuedYet indicates that the token hasn't been issued yet.
ErrRSAVerification is missing from crypto/ecdsa compared to crypto/rsa.

# Structs

FireAuth module to verify and extract information from Firebase JWT tokens.

# Interfaces

TokenVerifier verifies authenticaion tokens.