components

package
v0.0.0-...-358c224 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2016 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//JWTSecret Secret for creating JTW token - sha512sum da música "A lua me traiu, da 'Banca Calypso'"
	JWTSecret string = "" /* 128-byte string literal not displayed */
)

Variables

This section is empty.

Functions

func AuthHandler

func AuthHandler(response http.ResponseWriter, request *http.Request, routeParams httprouter.Params, jsonParams map[string]interface{})

AuthHandler Handles authorization

func GenerateJWTToken

func GenerateJWTToken(subject string, extraTime time.Duration) (tokenString string, err error)

GenerateJWTToken Generates the authenticaton token (JWT)

func GetEncodedPassword

func GetEncodedPassword(username *string) (password string, err error)

GetEncodedPassword Returns the encoded user password from DB

func GoAuthMiddleWare

func GoAuthMiddleWare(CH GoAuthHandler) httprouter.Handle

GoAuthMiddleWare Default Middleware

func JSONError

func JSONError(response http.ResponseWriter, errorString string, statusCode int)

JSONError Helper function to return restful errors

Types

type AccessToken

type AccessToken struct {
	AccessToken string `json:"access_token"`
}

AccessToken Representation for the return of AuthHandler

type GoAuthHandler

type GoAuthHandler func(
	response http.ResponseWriter,
	request *http.Request,
	routeParams httprouter.Params,
	jsonParams map[string]interface{})

GoAuthHandler Type for using to route callbacks

type InMemoryDatabase

type InMemoryDatabase struct {
	Permissions []Permission
	Users       map[string]User
}

InMemoryDatabase "De facto" where to search for information

type Permission

type Permission struct {
	Name string
}

Permission Struct defining permission's fields

type User

type User struct {
	Hash        string
	Username    string
	Password    string
	Permissions []Permission
}

User Struct defining user's fields

func GetUser

func GetUser(username string) (user User, err error)

GetUser Get the user from DB

Jump to

Keyboard shortcuts

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