auth

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FirebaseAuthTokenFromContext

func FirebaseAuthTokenFromContext(ctx context.Context) *auth.Token

FirebaseAuthTokenFromContext retrives the verified Firebase auth token from the current context

Types

type AuthConfig added in v0.0.15

type AuthConfig struct {
	// Enable Firebase auth
	FirebaseEnabled bool `env:"AUTH_FIREBASE_ENABLED"`

	// Path to Firebase credentials JSON file
	FirebaseCredentialsFile string `env:"AUTH_FIREBASE_CREDENTIALS_FILE"`

	// Firebase credentials JSON
	FirebaseCredentialsJSON string `env:"AUTH_FIREBASE_CREDENTIALS_JSON"`
}

type FirebaseAuth

type FirebaseAuth struct {
	// contains filtered or unexported fields
}

func FirebaseAuthFromContext added in v0.0.23

func FirebaseAuthFromContext(ctx context.Context) *FirebaseAuth

FirebaseAuthFromContext retrives FirebaseAuth from the current context

func NewFirebaseAuth

func NewFirebaseAuth(cfg AuthConfig) FirebaseAuth

func (*FirebaseAuth) FirebaseAuthMiddleware

func (a *FirebaseAuth) FirebaseAuthMiddleware() gin.HandlerFunc

FirebaseAuthMiddleware retrieves and verifies a Firebase auth token via a header or cookie and passes the token into the current context. It also adds the FirebaseAuth instance to the current context

func (*FirebaseAuth) FirebaseAuthSetUserClaims

func (a *FirebaseAuth) FirebaseAuthSetUserClaims(ctx context.Context, uid string, claims map[string]interface{}) error

FirebaseAuthSetUserClaims sets the user with the passed uid's token claims. This can then be verified either with the middleware associated with this struct or with any standard JWT verification process.

Jump to

Keyboard shortcuts

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