Documentation ¶
Overview ¶
Package auth provides handlers to enable basic auth support. Example:
import( "github.com/astaxie/beego" "github.com/ysqi/tokenauth2beego/o2o" ) func main(){ // authenticate every request beego.InsertFilter("*", beego.BeforeRouter, o2o.DefaultFileter()) beego.Run() }
Save and Get SingleToken Token:
token, err := o2o.Auth.NewSingleToken(userID)
Index ¶
- Constants
- Variables
- type Automatic
- func (a *Automatic) CheckToken(req *http.Request) (token *tokenauth.Token, err error)
- func (a *Automatic) ConvertoCookie(token *tokenauth.Token) *http.Cookie
- func (a *Automatic) ReturnFailueInfo(err error, ctx *context.Context)
- func (a *Automatic) SetTokenString(token *tokenauth.Token, w http.ResponseWriter)
Constants ¶
View Source
const (
TokenFieldName = "access_token"
)
Variables ¶
View Source
var ( ERR_ServerError = tokenauth.ValidationError{Code: "-1", Msg: "System error , Please retry"} ERR_UserIDEmpty = tokenauth.ValidationError{Code: "41020", Msg: "UserID is empty"} )
View Source
var (
EnableCookie = false // Save token string to cookie if enableCookie=true.
)
Functions ¶
This section is empty.
Types ¶
type Automatic ¶
type Automatic struct { TokenFunc tokenauth.GenerateTokenString SecretFunc tokenauth.GenerateSecretString }
func (*Automatic) CheckToken ¶
Check User Token from reqeust. First find Authorization from reqeust hearder, Then find access_token from reqeust form field. Returns effective token or error.
func (*Automatic) ConvertoCookie ¶
Returns a Cookie, Create by token info.
func (*Automatic) ReturnFailueInfo ¶
Write error info to response and abort request. e.g. response body:
{"errcode":"41001","errmsg":"Token is emtpy"}
func (*Automatic) SetTokenString ¶
func (a *Automatic) SetTokenString(token *tokenauth.Token, w http.ResponseWriter)
Save token string to Response Header and Cookie.
Click to show internal directories.
Click to hide internal directories.