apiauth

package
v0.0.0-...-5c9d632 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2022 License: Apache-2.0, Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package apiauth provides handlers to enable apiauth support.

Simple Usage:

import(
	"github.com/W3-Partha/Beego"
	"github.com/W3-Partha/Beego/server/web/filter/apiauth"
)

func main(){
	// apiauth every request
	beego.InsertFilter("*", beego.BeforeRouter,apiauth.APIBasicAuth("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 APIBasicAuth

func APIBasicAuth(appid, appkey string) web.FilterFunc

APIBasicAuth uses the basic appid/appkey as the AppIdToAppSecret

func APISecretAuth

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

APISecretAuth uses AppIdToAppSecret verify and

func Signature

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

Signature generates signature with appsecret/method/params/RequestURI

Types

type AppIDToAppSecret

type AppIDToAppSecret func(string) string

AppIDToAppSecret gets appsecret through appid

Jump to

Keyboard shortcuts

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