Documentation ¶
Overview ¶
Package psw is an API service for password authentication
Index ¶
- Constants
- func Config(c *Flags) func(a *App) error
- func Cryptor(a *App) error
- func Mailer(m *mailer.App) func(a *App) error
- func RandomString(strlen int) string
- type Account
- type Accounts
- type App
- func (a *App) Login(r *http.Request, args *LoginArgs, reply *LoginResp) error
- func (a *App) ParseJWT(r *http.Request) (ret *Cookie, err error)
- func (a *App) Profile(r *http.Request, args *EmptyArgs, reply *Cookie) error
- func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (a *App) UserList(r *http.Request, args *UserListArgs, reply *Accounts) error
- func (a *App) UserListCount(r *http.Request, args *UserListArgs, reply *RowCount) error
- func (a *App) UserSave(r *http.Request, args *UserSaveArgs, reply *int64) error
- func (a *App) UserSendToken(r *http.Request, args *UserSendTokenArgs, reply *int64) error
- func (a *App) UserSetPassword(r *http.Request, args *UserSetPasswordArgs, reply *int64) error
- type Cookie
- type EmptyArgs
- type Flags
- type LoginArgs
- type LoginResp
- type Profile
- type RowCount
- type TemplateVars
- type UserListArgs
- type UserSaveArgs
- type UserSendTokenArgs
- type UserSetPasswordArgs
Constants ¶
const (
// Bearer is a prefix of JWT header value
Bearer = "Bearer"
)
Variables ¶
This section is empty.
Functions ¶
func RandomString ¶
RandomString returns random string of strlen length with chars from [a-zA-Z0-9]
Types ¶
type Account ¶
type Account struct { ID int64 `xorm:"'id' pk autoincr"` Login string `xorm:"not null unique"` Group string Name string Password string Email string `xorm:"not null unique"` Phone string Data string // some account related data Disabled bool `xorm:"not null default 0"` Version int `xorm:"version"` // Optimistic Locking }
Account is a user account table
type App ¶
type App struct { Cryptor *securecookie.SecureCookie DB *database.DB Template *template.Template Log *logger.Log Mailer *mailer.App Config *Flags }
App - Класс сервера API
func (*App) ServeHTTP ¶
func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP - Хэндлер метода /auth
func (*App) UserListCount ¶
UserListCount - выборка строк из журнала
func (*App) UserSendToken ¶
UserSendToken - add token by email
func (*App) UserSetPassword ¶
UserSetPassword - set new password
type Flags ¶
type Flags struct { AppKey string `long:"psw_session_key" description:"Key to encode user session (default: random key reset on restart)"` BlockKey string `long:"psw_block_key" default:"T<8rYvXmgLBdND(YW}3QRcLwh4$4P5eq" description:"Key to encode session blocks (16,32 or 62 byte)"` FailDelay int `long:"psw_delay" default:"5" description:"Delay response when password wrong (seconds)"` AuthHeader string `long:"auth_token_header" default:"X-Elfire-Token" description:"Header field to store auth token"` AuthCookie string `long:"auth_token_cookie" default:"elfire_sso_token" description:"Cookie name to store auth token"` UIDHeader string `long:"uid_header" default:"X-Elfire-UID" description:"Header field to store user ID"` GIDHeader string `long:"gid_header" default:"X-Elfire-GID" description:"Header field to store group ID"` AdminGroup string `long:"adm_group" default:"admin" description:"Admin user group"` AdminEmail string `long:"adm_email" default:"ak@elfire.ru" description:"Admin user email"` AdminPass string `long:"adm_pass" description:"Admin user password (Default: set random & log)"` AdminPrefix []string `long:"adm_prefix" description:"Prefix of Admin allowed uri"` Template string `long:"psw_template" default:"messages.gohtml" description:"Mail templates file"` }
Flags is a package flags sample in form ready for use with github.com/jessevdk/go-flags
type LoginArgs ¶
type LoginArgs struct {
Login, Email, Password string
}
LoginArgs - аргументы метода Login
type TemplateVars ¶
type TemplateVars struct { User Account Scheme, Host string Meta map[string]string Data interface{} }
TemplateVars holds template variables
type UserListArgs ¶
UserListArgs - аргументы метода UserList
type UserSaveArgs ¶
type UserSaveArgs struct { ID int64 Notify, Disabled bool // send email to user Login, Name, Email, Group, Data string }
UserSaveArgs - аргументы метода UserSave
type UserSendTokenArgs ¶
type UserSendTokenArgs struct {
Email string
}
UserSendTokenArgs - аргументы метода UserSendToken
type UserSetPasswordArgs ¶
type UserSetPasswordArgs struct {
Password, Password2 string
}
UserSetPasswordArgs - аргументы метода UserSetPassword