Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrInvalidPassword invalid passwoird ErrInvalidPassword = errors.New(models.ErrInvalidPassword) ErrInvalidAccount = errors.New(models.ErrInvalidAccount) ErrAccountOccupied = errors.New(models.ErrOccupiedAccount) ErrNilAccount = errors.New(models.ErrNilAccount) ErrInvalidOrgJoinCode = errors.New(models.ErrInvalidOrgJoinCode) ErrOrgUnactivated = errors.New(models.ErrOrgUnActivated) )
View Source
var DefaultRefreshTokenHandler = func(context *Context, refreshTokenHandler func(*Context) (*tokens.Token, error)) { var ( w = context.Writer token, err = refreshTokenHandler(context) ) if err == nil && token != nil { apiResult := models.NewAPIResult(models.ErrNil, token, "refresh-token succeeded") models.SendJSON(w, apiResult) } else { if _, ok := models.ErrText[err.Error()]; ok { apiError := models.NewAPIError(err.Error(), "refresh-token failed with error: %v", models.ErrText[err.Error()]) models.SendJSON(w, apiError) } else { apiError := models.NewHTTPError(http.StatusInternalServerError, models.ErrInternal, "internal server error: %v", err.Error()) models.SendJSON(w, apiError) } } }
DefaultRefreshTokenHandler default refresh token handler
View Source
var DefaultSignInHandler = func(context *Context, authenticateHandler func(*Context) (*tokens.Token, error)) { var ( // req = context.Request w = context.Writer token, err = authenticateHandler(context) ) if err == nil && token != nil { apiResult := models.NewAPIResult(models.ErrNil, token, "sign-in succeeded") models.SendJSON(w, apiResult) } else { if _, ok := models.ErrText[err.Error()]; ok { apiError := models.NewAPIError(err.Error(), "sign-in failed with error: %v", models.ErrText[err.Error()]) models.SendJSON(w, apiError) } else { apiError := models.NewHTTPError(http.StatusInternalServerError, models.ErrInternal, "internal server error: %v", err.Error()) models.SendJSON(w, apiError) } } }
DefaultSignInHandler default sign-in behavior
View Source
var DefaultSignOutHandler = func(context *Context) {
}
DefaultSignOutHandler default sign-out behavior
View Source
var DefaultSignUpHandler = func(context *Context, registerHandler func(*Context) (*tokens.Token, error)) { var ( w = context.Writer token, err = registerHandler(context) ) if err == nil && token != nil { apiResult := models.NewAPIResult(models.ErrNil, token, "sign-up succeeded!") models.SendJSON(w, apiResult) } else { if _, ok := models.ErrText[err.Error()]; ok { apiError := models.NewAPIError(err.Error(), "sign-up failed with error: %v", models.ErrText[err.Error()]) models.SendJSON(w, apiError) } else { apiError := models.NewHTTPError(http.StatusInternalServerError, models.ErrInternal, "internal server error: %v", err.Error()) models.SendJSON(w, apiError) } } }
DefaultSignUpHandler default sign-up behavior
Functions ¶
This section is empty.
Types ¶
type Auth ¶
type Auth struct { *Config // contains filtered or unexported fields }
Auth authentication main struct
func (*Auth) GetProvider ¶
GetProvider get provider with name
func (*Auth) GetProviders ¶
GetProviders return registered providers
func (*Auth) RegisterProvider ¶
RegisterProvider register auth provider
type Config ¶
type Config struct { DB *gorm.DB AuthModel interface{} URLPrefix string MachineID string Logger *logger.AppLogger SignInHandler func(*Context, func(*Context) (*tokens.Token, error)) RefreshTokenHandler func(*Context, func(*Context) (*tokens.Token, error)) SignUpHandler func(*Context, func(*Context) (*tokens.Token, error)) SignOutHandler func(*Context) }
Config the config of auth
Click to show internal directories.
Click to hide internal directories.