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
Click to show internal directories.
Click to hide internal directories.