authenticatior

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyUserID    = errors.New("userID cannot be empty")
	ErrEmptyToken     = errors.New("authToken cannot be empty")
	ErrClientNotInit  = errors.New("auth client not initialized")
	ErrNoClaimsFound  = errors.New("verified token contained no claims")
	ErrUIDNotFound    = errors.New("UID not found in verified token or its claims")
	ErrUserIDMismatch = errors.New("userID mismatch")
)

Custom errors for better error handling

Functions

This section is empty.

Types

type Authenticator

type Authenticator interface {
	ValidateToken(ctx context.Context, userID string, authToken string) (map[string]interface{}, error)
	IsExpired(ctx context.Context, authToken string) (bool, error)
	IsValid(ctx context.Context, authToken string) (bool, error)
}

Authenticator defines the interface for authentication operations.

func InitializeAuth

func InitializeAuth(ctx context.Context, config *FirebaseConfig) (Authenticator, error)

InitializeAuth initializes the Firebase application and returns an Authenticator.

type FirebaseConfig

type FirebaseConfig struct {
	// Path to the service account key file
	ServiceAccountKeyPath string `json:"serviceAccountKeyPath" yaml:"serviceAccountKeyPath"`
	// Project ID (optional if using service account key)
	ProjectID string `json:"projectId" yaml:"projectId"`
	// Database URL (optional, for Realtime Database)
	DatabaseURL string `json:"database" yaml:"database"`

	APIKey            string `json:"apiKey" yaml:"apiKey"`
	AuthDomain        string `json:"authDomain" yaml:"authDomain"`
	StorageBucket     string `json:"storageBucket" yaml:"storageBucket"`
	MessagingSenderID string `json:"messagingSenderId" yaml:"messagingSenderId"`
	AppID             string `json:"appId" yaml:"appId"`
}

FirebaseConfig holds the configuration for Firebase initialization

Jump to

Keyboard shortcuts

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