apiauth

package module
v0.0.0-...-f843f26 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2014 License: MIT Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

apiauth

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultAuthType string = "MCAA"

* Just an identifier -- nothing special about it.

Functions

func AuthDenied

func AuthDenied(res http.ResponseWriter, req *http.Request)

func AuthRequired

func AuthRequired(res http.ResponseWriter, req *http.Request)

func Authenticate

func Authenticate() martini.Handler

* Before access is granted to protected areas, the person * must call a method that invokes the 'Authenticate' method * which will generate and return a token to the requester * provided that authenticate and are granted access.

func ComputeHmacSHA1

func ComputeHmacSHA1(message string, secret string) string

func CorsHandler

func CorsHandler() martini.Handler

func CreateNewToken

func CreateNewToken(tr *TokenRequest) (token string, err error)

func NotAuthRequired

func NotAuthRequired(res http.ResponseWriter, req *http.Request)

func NotRequired

func NotRequired() martini.Handler

func Required

func Required() martini.Handler

func SetAppAuthHandler

func SetAppAuthHandler(newHandler AppAuthHandler)

Types

type AppAuthHandler

type AppAuthHandler func(appKey string, userKey string) bool

* Signature and method used to authenticate a user * which is usually a callback to user code

type TokenInfo

type TokenInfo struct {
	Request  *TokenRequest
	Response *TokenResponse
	Nonce    int64
}

type TokenRequest

type TokenRequest struct {
	AppKey  string // well-known key embedded in the application
	AppHash string

	UserKey  string // Username and userKey are supplied by client via user entry
	UserHash string

	Nonce     int64 // likey the unix time; variable to help prevent signature duplication (throwat replay attacks)
	Signature string
}

* Token management

func (TokenRequest) ComputeHash

func (tr TokenRequest) ComputeHash(key, secret string) string

func (TokenRequest) ComputeSignature

func (tr TokenRequest) ComputeSignature() string

func (*TokenRequest) Sign

func (tr *TokenRequest) Sign()

type TokenResponse

type TokenResponse struct {
	AuthType string
	Token    string
}

func (TokenResponse) AuthHeaderString

func (tr TokenResponse) AuthHeaderString(secret string, nonce string) string

func (TokenResponse) ComputeSignature

func (tr TokenResponse) ComputeSignature(secret string, nonce string) string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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