auth

package
v1.4.7 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2021 License: MIT Imports: 18 Imported by: 1

Documentation

Index

Constants

View Source
const (
	FirebaseContextVal = "FIREBASE_ID_TOKEN"
)

Variables

This section is empty.

Functions

func AuthAPIKey

func AuthAPIKey(secret string) gin.HandlerFunc

func AuthAppEngineCron

func AuthAppEngineCron() gin.HandlerFunc

AppEngine cron authentication

func AuthInternalOnly added in v0.1.13

func AuthInternalOnly() gin.HandlerFunc

only allow internal ip ranges

func AuthJWT

func AuthJWT(client *fbauth.Client) gin.HandlerFunc

Gin middleware for JWT auth

func ElevateToAdmin

func ElevateToAdmin(ctx context.Context, client *fbauth.Client, uid string) error

add 'admin' claim to users JWT so they can perform admin actions (they still need to be authenticated with JWT)

func InitAuth

func InitAuth() (*fbauth.Client, error)

load firebase configuration and create the auth client expecting env variable FIREBASE_CONFIG_FILE

func RevokeAdmin

func RevokeAdmin(ctx context.Context, client *fbauth.Client, uid string) error

remove admin claim from users JWT so they can no longer perform admin actions

func VerifyAdmin

func VerifyAdmin(ctx context.Context, client *fbauth.Client, uid string) error

use user id to very if user is admin or not

func VerifyToken

func VerifyToken(c *gin.Context, client *fbauth.Client) (int, string, error)

use id_token provided in Authorization: Bearer [ID_TOKEN]

Types

type APIKey added in v0.3.3

type APIKey string

type RefreshResponse added in v0.2.0

type RefreshResponse struct {
	ExpiresIn    string `json:"expires_in"`
	TokenType    string `json:"token_type"`
	RefreshToken string `json:"refresh_token"`
	IDToken      string `json:"id_token"`
	UserID       string `json:"user_id"`
	ProjectID    string `json:"project_id"`
}

type RefreshToken added in v0.3.3

type RefreshToken string

Jump to

Keyboard shortcuts

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