sms

package
v0.0.0-...-d370aa6 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2016 License: MIT Imports: 12 Imported by: 0

README

elsa-auth/sms

GoDoc GoCard

elsa-auth/sms - phone number verify package for ELSA server applications.

Documentation

Overview

Package sms is an API service for authentication via SMS

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Config

func Config(c *Flags) func(a *App) error

Config sets config struct

func Cryptor

func Cryptor(a *App) error

Cryptor sets securecookie generator

func Hook

func Hook(f HookFunc) func(a *App) error

Hook sets onSuccess hook func

Types

type App

type App struct {
	Store   *kvstore.Store
	Hook    *HookFunc
	Cryptor *securecookie.SecureCookie
	Log     *logger.Log
	Config  *Flags
}

App - Класс сервера API

func New

func New(log *logger.Log, options ...func(a *App) error) (*App, error)

New - Class constructor

func (*App) Code

func (a *App) Code(r *http.Request, args *ArgsKey, reply *Resp) error

func (*App) Init

func (a *App) Init(r *http.Request, args *ArgsKey, reply *Resp) error

Init - если клиент уже авторизован вернуть Code=4, иначе - проверить остальные варианты

func (*App) InitForced

func (a *App) InitForced(r *http.Request, args *ArgsKey, reply *Resp) error

InitForced - если клиент уже авторизован, выполнить активацию, иначе - проверить остальные варианты

func (*App) Phone

func (a *App) Phone(r *http.Request, args *ArgsKey, reply *Resp) error

type ArgsKey

type ArgsKey struct {
	Key string
}
type Cookie struct {
	Phone string
	Stamp time.Time
}

type Flags

type Flags struct {
	smpp.Flags
	AppKey    string `long:"sms_session_key" description:"Key to encode user session (default: random key reset on restart)"`
	BlockKey  string `long:"sms_block_key" default:"T<8rYvXmgLBdND(YW}3QRcLwh4$4P5eq" description:"Key to encode session blocks (16,32 or 62 byte)"`
	FailDelay int    `long:"sms_delay" default:"5" description:"Delay response when password wrong (seconds)"`
	SmsRetry  int    `long:"sms_retry" default:"300" description:"Repeat SMS only after this period (seconds)"`
	StoreName string `long:"sms_code_file" default:"store.json" description:"File to store active sent codes at program exit"`
}

Flags is a package flags sample in form ready for use with github.com/jessevdk/go-flags

type HookFunc

type HookFunc func(ip, phone, repeat string) string

HookFunc вызывается при успехе проверки телефона

type PhoneData

type PhoneData struct {
	Phone string    `json:"phone"`
	Code  string    `json:"code"`
	Stamp time.Time `json:"stamp"`
}

func (PhoneData) Fetch

func (pd PhoneData) Fetch(buf []byte) (kvstore.StoreData, error)

func (PhoneData) Init

func (pd PhoneData) Init() (kvstore.StoreData, error)

type Resp

type Resp struct {
	Code                    int
	Data, Phone, IP, Status string
}

Directories

Path Synopsis
Package sms is an API service for authentication via SMS
Package sms is an API service for authentication via SMS

Jump to

Keyboard shortcuts

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