Documentation ¶
Overview ¶
Package apiauth provides handlers to enable apiauth support.
Simple Usage:
import( "github.com/whiliang/beego-multi-schema/v2" "github.com/whiliang/beego-multi-schema/v2/server/web/filter/apiauth" ) func main(){ // apiauth every request beego.InsertFilter("*", beego.BeforeRouter,apiauth.APIBaiscAuth("appid","appkey")) beego.Run() }
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))
Information:
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
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func APIBaiscAuth ¶
func APIBaiscAuth(appid, appkey string) beego.FilterFunc
APIBaiscAuth calls APIBasicAuth for previous callers
func APIBasicAuth ¶
func APIBasicAuth(appid, appkey string) beego.FilterFunc
APIBasicAuth use the basic appid/appkey as the AppIdToAppSecret
func APISecretAuth ¶
func APISecretAuth(f AppIDToAppSecret, timeout int) beego.FilterFunc
APISecretAuth use AppIdToAppSecret verify and
Types ¶
type AppIDToAppSecret ¶
type AppIDToAppSecret apiauth.AppIDToAppSecret
AppIDToAppSecret is used to get appsecret throw appid
Click to show internal directories.
Click to hide internal directories.