Skip to content

GFA is a package of gin middlewares to handle authentification using Google Firebase.

License

Notifications You must be signed in to change notification settings

Alvarios/gin-firebase-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gin-Firebase-Auth (GFA)

GFA is a package of gin middlewares to handle authentification using Google Firebase.

Setup

First, you need to initialize your firebase app. Once you have your app variable, create a new GFA config object:

config := gfa.Handler{}
config.Init(app) // Pass your firebase app variable.

gfaHandler will automatically declare some firebase objects to use inside middlewares.

Middlewares

Each gfa middlewares use a wrapper, to pass in some parameters. To declare them, use :

router.METHOD(
    path,
    mid(config, ...opts),
    ...
)

Each section comes with a how-to-use example, for better clarity.

VerifyToken

Option Type Description
nonRestrictivePolicy bool When authentication fails, the request is aborted with an unauthorized status.
Set this flag to true to override this behavior.

Go handles auth with credentials from its own api. Once an user is logged, each secure request will be issued with an Authorization header, containing a token id that handles credentials.

VerifyToken will check and decode this token.

package main

import "github.com/Alvarios/gin-firebase-auth"

func main() {
    // Set your gin and gfa apps here.
    
    router.GET(
        "/path/to/resource1",
        gfa.VerifyToken(config, false),
        GetResource1,   // Use your own functions here.
        Render,
    )
}

Copyright

2020 Kushuh - MIT license

About

GFA is a package of gin middlewares to handle authentification using Google Firebase.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages