apiauth

package
v0.0.0-...-eca3c71 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2014 License: Apache-2.0, MIT Imports: 9 Imported by: 0

Documentation

Overview

Package apiauth provides handlers to enable apiauth support.

Simple Usage:

import(
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/plugins/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.APIAuthWithFunc(getAppSecret, 360))

Infomation:

In the request user should include these params in the query

1. appid

appid is asigned 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 APIAuthWithFunc

func APIAuthWithFunc(f AppIdToAppSecret, timeout int) beego.FilterFunc

func APIBaiscAuth

func APIBaiscAuth(appid, appkey string) beego.FilterFunc

func Signature

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

Types

type AppIdToAppSecret

type AppIdToAppSecret func(string) string

Jump to

Keyboard shortcuts

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