authflow

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractClientIP

func ExtractClientIP(remoteAddr string) string

ExtractClientIP extracts client IP from request This can be enhanced to check X-Forwarded-For headers

Types

type AppServiceAdapter

type AppServiceAdapter struct {
	AppService interface {
		GetCookieConfig(ctx context.Context, appID xid.ID) (*session.CookieConfig, error)
	}
}

AppServiceAdapter adapts app.AppService to AppServiceInterface

func (*AppServiceAdapter) GetCookieConfig

func (a *AppServiceAdapter) GetCookieConfig(ctx context.Context, appID xid.ID) (*session.CookieConfig, error)

type AppServiceInterface

type AppServiceInterface interface {
	GetCookieConfig(ctx context.Context, appID xid.ID) (*session.CookieConfig, error)
}

AppServiceInterface defines methods needed from app service AppService is accessed via ServiceImpl.App

type AuditServiceInterface

type AuditServiceInterface interface {
	Log(ctx context.Context, userID *xid.ID, action, target, ipAddress, userAgent, metadata string) error
}

AuditServiceInterface defines methods needed from audit service

type AuthServiceInterface

type AuthServiceInterface interface {
	SignUp(ctx context.Context, req *auth.SignUpRequest) (*responses.AuthResponse, error)
	SignIn(ctx context.Context, req *auth.SignInRequest) (*responses.AuthResponse, error)
	CreateSessionForUser(ctx context.Context, u *user.User, remember bool, ipAddress, userAgent string) (*responses.AuthResponse, error)
}

AuthServiceInterface defines methods needed from auth service This interface is implemented by core/auth.Service

type CompleteAuthenticationRequest

type CompleteAuthenticationRequest struct {
	User         *user.User
	RememberMe   bool
	IPAddress    string
	UserAgent    string
	Context      context.Context
	ForgeContext forge.Context
	AuthMethod   string // "email", "social", "passkey", "mfa", etc.
	AuthProvider string // "google", "github", etc. for social
}

CompleteAuthenticationRequest contains all data needed to complete authentication

type CompleteSignUpOrSignInRequest

type CompleteSignUpOrSignInRequest struct {
	Email        string     // Email for new user signup
	Password     string     // Password for new user (may be empty for OAuth/magic link)
	Name         string     // Name for new user
	User         *user.User // Existing user (for signin flow)
	IsNewUser    bool       // True if this is a signup, false if signin
	RememberMe   bool
	IPAddress    string
	UserAgent    string
	Context      context.Context
	ForgeContext forge.Context
	AuthMethod   string // "social", "magiclink", "email", etc.
	AuthProvider string // e.g., "github", "google"
}

CompleteSignUpOrSignInRequest contains all data needed for signup or signin completion

type CompletionService

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

CompletionService handles the final steps of authentication

func NewCompletionService

func NewCompletionService(
	authService AuthServiceInterface,
	deviceService DeviceServiceInterface,
	auditService AuditServiceInterface,
	appService AppServiceInterface,
	cookieConfig *session.CookieConfig,
) *CompletionService

NewCompletionService creates a new authentication completion service

func (*CompletionService) CompleteAuthentication

func (s *CompletionService) CompleteAuthentication(req *CompleteAuthenticationRequest) (*responses.AuthResponse, error)

CompleteAuthentication handles all post-authentication steps

func (*CompletionService) CompleteSignUpOrSignIn

func (s *CompletionService) CompleteSignUpOrSignIn(req *CompleteSignUpOrSignInRequest) (*responses.AuthResponse, error)

CompleteSignUpOrSignIn handles signup for new users or signin for existing users This method ensures proper membership creation through decorated auth services

type DeviceServiceAdapter

type DeviceServiceAdapter struct {
	DeviceService *device.Service
}

DeviceServiceAdapter adapts device.Service to DeviceServiceInterface

func (*DeviceServiceAdapter) TrackDevice

func (d *DeviceServiceAdapter) TrackDevice(ctx context.Context, appID, userID xid.ID, fingerprint, userAgent, ipAddress string) (*device.Device, error)

type DeviceServiceInterface

type DeviceServiceInterface interface {
	TrackDevice(ctx context.Context, appID, userID xid.ID, fingerprint, userAgent, ipAddress string) (*device.Device, error)
}

DeviceServiceInterface defines methods needed from device service

Jump to

Keyboard shortcuts

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