auth

package
v1.0.53 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateAPIKey

func GenerateAPIKey() string

GenerateAPIKey generates a new API key The key is returned in its raw form, it should be hashed before storing in config

func HashAPIKey

func HashAPIKey(key string) string

HashAPIKey creates a SHA-256 hash of the API key

func NewFlexpriceAuth

func NewFlexpriceAuth(cfg *config.Configuration) *flexpriceAuth

func ValidateAPIKey

func ValidateAPIKey(cfg *config.Configuration, key string) (string, string, bool)

ValidateAPIKey validates an API key against the configuration Returns the tenant ID and user ID if valid, empty strings if invalid

Types

type AuthRequest

type AuthRequest struct {
	UserID   string
	TenantID string
	Email    string
	Password string
	Token    string
}

AuthRequest we create this by first checking the email in the DB and if found we set the user and tenant id and then with this request we try to validate the saved provider token with the user provided input and get the auth token

type AuthResponse

type AuthResponse struct {
	// ProviderToken is the fixed identifier or code provided by the provider
	// for example, in Supabase, it's the user ID and for Flexprice, it's the hashed password
	ProviderToken string
	// AuthToken is the token used to authenticate with the application or the generated
	// jwt token for the user
	AuthToken string
	// ID is the ID of the user
	ID string
}

type Provider

type Provider interface {

	// User Management
	GetProvider() types.AuthProvider
	SignUp(ctx context.Context, req AuthRequest) (*AuthResponse, error)
	Login(ctx context.Context, req AuthRequest, userAuthInfo *auth.Auth) (*AuthResponse, error)
	ValidateToken(ctx context.Context, token string) (*auth.Claims, error)
	AssignUserToTenant(ctx context.Context, userID string, tenantID string) error

	// Customer Dashboard Token Management
	GenerateSessionToken(customerID, externalCustomerID, tenantID, environmentID string, timeoutHours int) (string, time.Time, error)
	ValidateSessionToken(ctx context.Context, token string) (*auth.SessionClaims, error)
}

func NewProvider

func NewProvider(cfg *config.Configuration) Provider

func NewSupabaseAuth

func NewSupabaseAuth(cfg *config.Configuration) Provider

Jump to

Keyboard shortcuts

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