Documentation ¶
Index ¶
- Variables
- func Activate(authCtx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
- func AddGroupToUser(authCtx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
- func BasicMngrHandler(authCtx *AuthContext, rw http.ResponseWriter, req *http.Request, ...)
- func ChangePassword(authCtx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
- func CreateGroup(authCtx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
- func CreatePasswordResetIssue(ctx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
- func CreateUser(ctx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
- func DeleteGroup(ctx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
- func DeleteSettings(ctx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
- func DeleteUser(authCtx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
- func GetGroup(ctx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
- func GetSettings(ctx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
- func GetToken(authCtx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
- func GetUser(authCtx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
- func JSONError(rw http.ResponseWriter, message string, code int)
- func ListGroup(authCtx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
- func ListUser(authCtx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
- func OverridePassword(authCtx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
- func RedirectPasswordReset(ctx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
- func RemoveGroupFromUser(authCtx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
- func ResetPassword(authCtx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
- func Serve(router *mux.Router)
- func SignUp(authCtx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
- func UpdateApprovedStatus(authCtx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
- func UpdateGroup(ctx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
- func UpdateSettings(ctx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
- func UpdateUserProfile(authCtx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
- type AuthContext
- type Condition
- type HandleFunc
- type Logger
- type Notificator
- type SysLogger
- func (l *SysLogger) Criticalf(format string, args ...interface{})
- func (l *SysLogger) Debugf(format string, args ...interface{})
- func (l *SysLogger) Errorf(format string, args ...interface{})
- func (l *SysLogger) Infof(format string, args ...interface{})
- func (l *SysLogger) Warningf(format string, args ...interface{})
Constants ¶
This section is empty.
Variables ¶
var ( // HANDLER_REGISTER should be "overided" by the "manager". Implement of this function // must use the "or" logic for the conditions. HANDLER_REGISTER func(fn HandleFunc, owner bool, pri []string) http.Handler // DEFAULT_NOTIFICATOR should be "overided" by the "manager". DEFAULT_NOTIFICATOR Notificator // DEFAULT_LOGGER should be "overided" by the "manager". DEFAULT_LOGGER Logger OnlineThreshold = time.Hour HandleTimeout = time.Minute * 2 )
var ( ErrInvalidCredential = errors.New("kidstuff/auth: Invalid emaill or password") ErrInvalidId = errors.New("kidstuff/auth: Invalif Id") ErrInvalidActiveCode = errors.New("kidstuff/auth: Invalid activate code") ErrInvalidResetCode = errors.New("kidstuff/auth: Invalid reset code") ErrForbidden = errors.New("kidstuff/auth: Forbidden") ErrPwdMismatch = errors.New("kidstuff/auth: Pwd and PwdRepeat doesn't match") ErrNoKeyProvided = errors.New("kidstuff/auth: no key provided") ErrMailFailed = errors.New("kidstuff/auth: email send failed") )
Functions ¶
func Activate ¶
func Activate(authCtx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
Activate handle user activation action. If success change user Approved to true. Details: http://kidstuff.github.io/swagger/#!/default/users_user_id_active_get
func AddGroupToUser ¶
func AddGroupToUser(authCtx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
AddGroupToUser add group to user. Require "manage_user" privilege. Details: http://kidstuff.github.io/swagger/#!/default/users_user_id_groups_put
func BasicMngrHandler ¶
func BasicMngrHandler(authCtx *AuthContext, rw http.ResponseWriter, req *http.Request, cond *Condition, fn HandleFunc)
BasicMngrHandler can be use in "manager" ServeHTTP after initital required interface like authmodel.UserManager, authmodel.GroupManager, conf.Configurator...etc
func ChangePassword ¶
func ChangePassword(authCtx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
ChangePassword document: http://kidstuff.github.io/swagger/#!/default/users_user_id_password_put
func CreateGroup ¶
func CreateGroup(authCtx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
CreateGroup document: http://kidstuff.github.io/swagger/#!/default/groups_post
func CreatePasswordResetIssue ¶
func CreatePasswordResetIssue(ctx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
func CreateUser ¶
func CreateUser(ctx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
CreateUser handle create new user accoutn action. Require "manage_user" privilege. Details: http://kidstuff.github.io/swagger/#!/default/users_post
func DeleteGroup ¶
func DeleteGroup(ctx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
DeleteGroup document: http://kidstuff.github.io/swagger/#!/default/groups_group_id_delete
func DeleteSettings ¶
func DeleteSettings(ctx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
DeleteSettings document: http://kidstuff.github.io/swagger/#!/default/settings_delete
func DeleteUser ¶
func DeleteUser(authCtx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
DeleteUser handle delete user account action. Require "manage_user" privilege. Details: http://kidstuff.github.io/swagger/#!/default/users_user_id_delete
func GetGroup ¶
func GetGroup(ctx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
GetGroup document: http://kidstuff.github.io/swagger/#!/default/groups_group_id_get
func GetSettings ¶
func GetSettings(ctx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
GetSettings document: http://kidstuff.github.io/swagger/#!/default/settings_get
func GetToken ¶
func GetToken(authCtx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
GetToken handle 'login' action. The token return use to verify later reuqest. Details: http://kidstuff.github.io/swagger/#!/default/tokens_get
func GetUser ¶
func GetUser(authCtx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
GetUser return full user account data. Require "manage_user" privilege. Details: http://kidstuff.github.io/swagger/#!/default/users_user_id_get
func JSONError ¶
func JSONError(rw http.ResponseWriter, message string, code int)
JSONError is a helper function to write json error message to http.ResponseWriter
func ListGroup ¶
func ListGroup(authCtx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
ListGroup document: http://kidstuff.github.io/swagger/#!/default/groups_get
func ListUser ¶
func ListUser(authCtx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
ListUser handle user list action. Require "manage_user" privilege. Details: http://kidstuff.github.io/swagger/#!/default/users_get
func OverridePassword ¶
func OverridePassword(authCtx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
OverridePassword document: http://kidstuff.github.io/swagger/#!/default/users_user_id_password_override_put
func RedirectPasswordReset ¶
func RedirectPasswordReset(ctx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
func RemoveGroupFromUser ¶
func RemoveGroupFromUser(authCtx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
RemoveGroupFromUser document: http://kidstuff.github.io/swagger/#!/default/users_user_id_groups_group_id_delete
func ResetPassword ¶
func ResetPassword(authCtx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
ResetPassword document: http://kidstuff.github.io/swagger/#!/default/users_user_id_password_reset_put
func SignUp ¶
func SignUp(authCtx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
SignUp handle registration action. Details: http://kidstuff.github.io/swagger/#!/default/signup_post
func UpdateApprovedStatus ¶
func UpdateApprovedStatus(authCtx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
UpdateApprovedStatus handle user arppoval status update action. Require "manage_user" privilege. Details: http://kidstuff.github.io/swagger/#!/default/users_user_id_approve_put
func UpdateGroup ¶
func UpdateGroup(ctx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
UpdateGroup document: http://kidstuff.github.io/swagger/#!/default/groups_group_id_patch
func UpdateSettings ¶
func UpdateSettings(ctx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
UpdateSettings document: http://kidstuff.github.io/swagger/#!/default/settings_patch
func UpdateUserProfile ¶
func UpdateUserProfile(authCtx *AuthContext, rw http.ResponseWriter, req *http.Request) (int, error)
UpdateUserProfile handle user's profile update action. Require "owner" or "manage_user" privilege. Details: http://kidstuff.github.io/swagger/#!/default/users_user_id_profile_patch
Types ¶
type AuthContext ¶
type AuthContext struct { Auth authmodel.Manager Settings conf.Configurator Notifications Notificator Logs Logger // contains filtered or unexported fields }
func (*AuthContext) ValidCurrentUser ¶
ValidCurrentUser validate user privilege and cacuate user total privilege base on groups. In some case a non-nil *authmodel.User object still return with an error.
type HandleFunc ¶
type HandleFunc func(*AuthContext, http.ResponseWriter, *http.Request) (int, error)
type Logger ¶
type Logger interface { // Debugf formats its arguments according to the format, analogous to fmt.Printf, // and records the text as a log message at Debug level. Debugf(format string, args ...interface{}) // Infof is like Debugf, but at Info level. Infof(format string, args ...interface{}) // Warningf is like Debugf, but at Warning level. Warningf(format string, args ...interface{}) // Errorf is like Debugf, but at Error level. Errorf(format string, args ...interface{}) // Criticalf is like Debugf, but at Critical level. Criticalf(format string, args ...interface{}) }
type Notificator ¶
type Notificator interface {
SendMail(ctx *AuthContext, subject, message, from, to string) error
}
type SysLogger ¶
func NewSysLogger ¶
func (*SysLogger) Debugf ¶
Debugf formats its arguments according to the format, analogous to fmt.Printf, and records the text as a log message at Debug level.