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 ¶
HashAPIKey creates a SHA-256 hash of the API key
func NewFlexpriceAuth ¶
func NewFlexpriceAuth(cfg *config.Configuration) *flexpriceAuth
func ValidateAPIKey ¶
ValidateAPIKey validates an API key against the configuration Returns the tenant ID and user ID if valid, empty strings if invalid
Types ¶
type AuthRequest ¶
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
}
func NewProvider ¶
func NewProvider(cfg *config.Configuration) Provider
func NewSupabaseAuth ¶
func NewSupabaseAuth(cfg *config.Configuration) Provider
Click to show internal directories.
Click to hide internal directories.