beego: Index | Files

package apiauth

import ""

Package apiauth provides handlers to enable apiauth support.

Simple Usage:


func main(){
	// apiauth every request
	beego.InsertFilter("*", beego.BeforeRouter,apiauth.APIBaiscAuth("appid","appkey"))

Advanced Usage:

func getAppSecret(appid string) string {
	// get appsecret by appid
	// maybe store in configure, maybe in database

beego.InsertFilter("*", beego.BeforeRouter,apiauth.APISecretAuth(getAppSecret, 360))


In the request user should include these params in the query

1. appid

appid is assigned to the application

2. signature

get the signature use apiauth.Signature()

when you send to server remember use url.QueryEscape()

3. timestamp:

send the request time, the format is yyyy-mm-dd HH:ii:ss


Package Files


func APIBaiscAuth Uses

func APIBaiscAuth(appid, appkey string) beego.FilterFunc

APIBaiscAuth calls APIBasicAuth for previous callers

func APIBasicAuth Uses

func APIBasicAuth(appid, appkey string) beego.FilterFunc

APIBasicAuth use the basic appid/appkey as the AppIdToAppSecret

func APISecretAuth Uses

func APISecretAuth(f AppIDToAppSecret, timeout int) beego.FilterFunc

APISecretAuth use AppIdToAppSecret verify and

func Signature Uses

func Signature(appsecret, method string, params url.Values, RequestURL string) (result string)

Signature used to generate signature with the appsecret/method/params/RequestURI

type AppIDToAppSecret Uses

type AppIDToAppSecret func(string) string

AppIDToAppSecret is used to get appsecret throw appid

Package apiauth imports 10 packages (graph). Updated 2019-07-22. Refresh now. Tools for package owners.