firebase

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ContextKey = "user"

	ErrMissing = xerror.NewHTTPError(http.StatusBadRequest, "missing or malformed firebase")
	ErrInvalid = xerror.NewHTTPError(http.StatusUnauthorized, "invalid or expired firebase")
)

Functions

func ContextToken

func ContextToken(c *gin.Context) (*auth.Token, error)

func Next

func Next(projectID, credentialsFile string) gin.HandlerFunc

Next config

func NextSuccessHandler

func NextSuccessHandler(projectID, credentialsFile string, handler middleware.SuccessHandler) gin.HandlerFunc

NextSuccessHandler SuccessHandler config

func NextWithAuthClient

func NextWithAuthClient(authClient *AuthClient) gin.HandlerFunc

NextWithAuthClient firebase AuthClient

func NextWithAuthClientSuccessHandler

func NextWithAuthClientSuccessHandler(authClient *AuthClient, handler middleware.SuccessHandler) gin.HandlerFunc

NextWithAuthClientSuccessHandler firebase AuthClient and middleware.SuccessHandler

func NextWithConfig

func NextWithConfig(config FirebaseConfig) gin.HandlerFunc

Types

type AuthClient

type AuthClient struct {
	ApiKey string
	Ctx    context.Context
	*auth.Client
}

func (AuthClient) TokenToIDToken

func (f AuthClient) TokenToIDToken(token string) (IDToken, error)

TokenToIDToken https://firebase.google.com/docs/reference/rest/auth?hl=zh-cn

type FirebaseConfig

type FirebaseConfig struct {
	// Skipper defines a function to skip middleware.
	Skipper middleware.Skipper
	// middleware or handler.
	SuccessHandler middleware.SuccessHandler
	// ErrorHandler defines a function which is executed for an invalid token.
	// It may be used to define a custom JWT error.
	ErrorHandler middleware.ErrorHandler
	// Context key to store user information from the token into context.
	// Optional. Default value "user".
	ContextKey string
	// TokenLookup is a string in the form of "<source>:<name>" or "<source>:<name>,<source>:<name>" that is used
	// to extract token from the request.
	// Optional. Default value "header:Authorization".
	// Possible values:
	// - "header:<name>" or "header:<name>:<cut-prefix>"
	// 			`<cut-prefix>` is argument value to cut/trim prefix of the extracted value. This is useful if header
	//			value has static prefix like `Authorization: <auth-scheme> <authorisation-parameters>` where part that we
	//			want to cut is `<auth-scheme> ` note the space at the end.
	//			In case of JWT tokens `Authorization: Bearer <token>` prefix we cut is `Bearer `.
	// If prefix is left empty the whole value is returned.
	// - "query:<name>"
	// - "param:<name>"
	// - "cookie:<name>"
	// - "form:<name>"
	// Multiple sources example:
	// - "header:Authorization,cookie:myowncookie"
	TokenLookup string
	// AuthScheme to be used in the Authorization header.
	// Optional. Default value "Bearer".
	AuthScheme string
	//NewAuthClient
	AuthClient *AuthClient
}

FirebaseConfig defines the config for BasicAuth middleware.

type IDToken

type IDToken struct {
	IDToken      string `json:"idToken"`
	RefreshToken string `json:"refreshToken"`
	ExpiresIn    string `json:"expiresIn"`
}

Jump to

Keyboard shortcuts

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