Documentation
¶
Overview ¶
Package beaconauth provides a modular, plugin-based authentication library for Go
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( WithSecret = core.WithSecret WithBaseURL = core.WithBaseURL WithBasePath = core.WithBasePath WithAdapter = core.WithAdapter WithPlugins = core.WithPlugins WithMailer = core.WithMailer WithOAuthProviders = core.WithOAuthProviders WithRateLimit = core.WithRateLimit WithSessionConfig = core.WithSessionConfig WithEmailPassword = core.WithEmailPassword WithLogger = core.WithLogger WithTrustedOrigins = core.WithTrustedOrigins )
Configuration options
View Source
var ( ErrInvalidCredentials = core.ErrInvalidCredentials ErrUserNotFound = core.ErrUserNotFound ErrSessionNotFound = core.ErrSessionNotFound ErrSessionExpired = core.ErrSessionExpired ErrEmailTaken = core.ErrEmailTaken ErrInvalidEmail = core.ErrInvalidEmail ErrInvalidPassword = core.ErrInvalidPassword ErrEmailNotVerified = core.ErrEmailNotVerified ErrForbidden = core.ErrForbidden ErrNotFound = core.ErrNotFound ErrBadRequest = core.ErrBadRequest ErrInternalServer = core.ErrInternalServer )
Common errors
Functions ¶
This section is empty.
Types ¶
type Auth ¶
Auth is the main authentication interface
func New ¶
New creates a new BeaconAuth instance
Example ¶
package main
import (
"fmt"
"log"
beaconauth "github.com/marshallshelly/beacon-auth"
"github.com/marshallshelly/beacon-auth/adapters/memory"
)
type SilentLogger struct{}
func (l *SilentLogger) Debug(msg string, fields ...interface{}) {}
func (l *SilentLogger) Info(msg string, fields ...interface{}) {}
func (l *SilentLogger) Warn(msg string, fields ...interface{}) {}
func (l *SilentLogger) Error(msg string, fields ...interface{}) {}
func main() {
// Initialize memory adapter
adapter := memory.New()
// Initialize BeaconAuth with silent logger to avoid random output in test
authInstance, err := beaconauth.New(
beaconauth.WithAdapter(adapter),
beaconauth.WithSecret("test-secret-key-must-be-32-bytes-long!"),
beaconauth.WithBaseURL("http://localhost:3000"),
beaconauth.WithLogger(&SilentLogger{}),
)
if err != nil {
log.Fatal(err)
}
defer authInstance.Close()
fmt.Println("BeaconAuth initialized successfully")
}
Output: BeaconAuth initialized successfully
Click to show internal directories.
Click to hide internal directories.