auth

package
v1.16.63 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoginWithEmailAndPasswordHandler

func LoginWithEmailAndPasswordHandler(getUserByEmail func(email string) (AuthUserEmail, error)) func(c *fiber.Ctx) error

func LoginWithEmailOTPHandler added in v1.15.5

func LoginWithEmailOTPHandler(getUserByEmail func(email string) (AuthUserEmail, error)) func(c *fiber.Ctx) error

LoginWithEmailOTPHandler initiates an OTP flow by generating an OTP, storing it in Redis (5 min expiration), and emailing it to the user.

func LoginWithPhoneOTPHandler

func LoginWithPhoneOTPHandler(getUserByPhone func(phone string) (AuthUserPhone, error)) func(c *fiber.Ctx) error

func VerifyEmailOTPHandler added in v1.15.5

func VerifyEmailOTPHandler(getUserByEmail func(email string) (AuthUserEmail, error)) func(c *fiber.Ctx) error

VerifyEmailOTPHandler verifies the OTP sent to email and returns a JWT. If the user exists, user-specific claims are added.

func VerifyPhoneOTPHandler

func VerifyPhoneOTPHandler(getUserByPhone func(phone string) (AuthUserPhone, error)) func(c *fiber.Ctx) error

Types

type AuthUserEmail

type AuthUserEmail interface {
	GetEmail() string
	GetPassword() string
	GetID() string
	JWTClaimsProvider
}

func NewAuthUserEmail added in v1.2.23

func NewAuthUserEmail(email, password, id string) AuthUserEmail

type AuthUserPhone

type AuthUserPhone interface {
	GetPhone() string
	GetPassword() string
	GetID() string
	JWTClaimsProvider
}

func NewAuthUserPhone added in v1.2.23

func NewAuthUserPhone(phone, password, id string) AuthUserPhone

type GoogleAuth added in v1.2.12

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

func InitializeGoogleAuth added in v1.2.12

func InitializeGoogleAuth(config models.GoogleConfig) *GoogleAuth

func NewGoogleAuth added in v1.2.12

func NewGoogleAuth(config models.GoogleConfig) *GoogleAuth

func (*GoogleAuth) GetGoogleOauthURL added in v1.2.12

func (ga *GoogleAuth) GetGoogleOauthURL() string

func (*GoogleAuth) GetSessionData added in v1.2.19

func (ga *GoogleAuth) GetSessionData() func(c *fiber.Ctx) error

func (*GoogleAuth) GoogleCallbackBuilder added in v1.2.12

func (ga *GoogleAuth) GoogleCallbackBuilder(callbackHandler func(c *fiber.Ctx, user *models.GoogleCallbackData, tokenSess *session.Session) error) func(c *fiber.Ctx) error

func (*GoogleAuth) GoogleHandleCallback added in v1.2.12

func (ga *GoogleAuth) GoogleHandleCallback() func(c *fiber.Ctx) error

func (*GoogleAuth) GoogleLoginBuilder added in v1.2.12

func (ga *GoogleAuth) GoogleLoginBuilder(authHandler func(c *fiber.Ctx) error) func(c *fiber.Ctx) error

func (*GoogleAuth) GoogleLoginHandler added in v1.2.12

func (ga *GoogleAuth) GoogleLoginHandler() func(c *fiber.Ctx) error

func (*GoogleAuth) IsGoogleAuthenticated added in v1.2.12

func (ga *GoogleAuth) IsGoogleAuthenticated(c *fiber.Ctx) bool

func (*GoogleAuth) RequireGoogleAuth added in v1.2.12

func (ga *GoogleAuth) RequireGoogleAuth() func(c *fiber.Ctx) error

type GoogleCallbackData added in v1.2.15

type GoogleCallbackData struct {
	Email         string `json:"email"`
	Name          string `json:"name"`
	Picture       string `json:"picture"`
	VerifiedEmail bool   `json:"verified_email"`
	ID            string `json:"id"`
}

type JWTClaimsProvider

type JWTClaimsProvider interface {
	AdditionalClaims() map[string]interface{}
	SetAdditionalClaims(claims map[string]interface{})
}

type LoginWithEmailAndPasswordRequest

type LoginWithEmailAndPasswordRequest struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

type LoginWithEmailOTPRequest added in v1.15.5

type LoginWithEmailOTPRequest struct {
	Email string `json:"email"`
}

Email OTP request payloads

type LoginWithPhoneOTPRequest

type LoginWithPhoneOTPRequest struct {
	Phone string `json:"phone"`
}

type ResponseHTTP

type ResponseHTTP struct {
	Success bool        `json:"success"`
	Data    interface{} `json:"data"`
	Message string      `json:"message"`
}

type User added in v1.2.23

type User struct {
	Id          string                 `json:"id"`
	Email       string                 `json:"email"`
	Phone       string                 `json:"phone"`
	Password    string                 `json:"password"`
	AddedClaims map[string]interface{} `json:"additional_claims"`
}

func (*User) AdditionalClaims added in v1.2.23

func (u *User) AdditionalClaims() map[string]interface{}

func (*User) GetEmail added in v1.2.23

func (u *User) GetEmail() string

func (*User) GetID added in v1.2.23

func (u *User) GetID() string

func (*User) GetJWTClaims added in v1.2.23

func (u *User) GetJWTClaims() map[string]interface{}

func (*User) GetPassword added in v1.2.23

func (u *User) GetPassword() string

func (*User) GetPhone added in v1.2.23

func (u *User) GetPhone() string

func (*User) SetAdditionalClaims added in v1.3.34

func (u *User) SetAdditionalClaims(claims map[string]interface{})

type VerifyEmailOTPRequest added in v1.15.5

type VerifyEmailOTPRequest struct {
	Email string `json:"email"`
	OTP   string `json:"otp"`
}

type VerifyPhoneOTPRequest

type VerifyPhoneOTPRequest struct {
	Phone string `json:"phone"`
	OTP   string `json:"otp"`
}

Jump to

Keyboard shortcuts

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