kongojwt

package module
v0.0.0-...-6cdb09e Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2016 License: MIT Imports: 7 Imported by: 0

README

Kongo-JWT

Small library to handle JWT token release.

Usage

See server.go in the example directory

Negroni support

There is a middleware for Negroni to retrive authenticated user. See the example server.go in example directory.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JWTResult

type JWTResult struct {
	Algorithm  string `json:"algorithm"`
	ConsumerID string `json:"consumer_id"`
	CreatedAt  int    `json:"created_at"`
	ID         string `json:"id"`
	Key        string `json:"key"`
	Secret     string `json:"secret"`
}

JSON ritornato quando si crea il JWT

type JWTResults

type JWTResults struct {
	Data  []JWTResult `json:"data"`
	Total int         `json:"total"`
}

type KongCustomer

type KongCustomer struct {
	CreatedAt int    `json:"created_at"`
	CustomID  string `json:"custom_id"`
	ID        string `json:"id"`
	Username  string `json:"username"`
}

JSON returned from new user request

type KongData

type KongData struct {
	Customer   KongCustomer
	JWTResult  JWTResult
	JWTResults JWTResults
	Username   string
	CustomID   string
	Token      string
	Server     string
}

type KongMiddleware

type KongMiddleware struct {
}

func AuthMiddleware

func AuthMiddleware() *KongMiddleware

Middleware is a struct that has a ServeHTTP method

func (*KongMiddleware) ServeHTTP

func (l *KongMiddleware) ServeHTTP(w http.ResponseWriter, req *http.Request, next http.HandlerFunc)

The middleware handler

type KongUser

type KongUser struct {
	KongID   string `json:"kong_id"`  // Kong internal ID
	Username string `json:"username"` // Username
	ID       string `json:"id"`       // Custom id
}

type KongoJWT

type KongoJWT struct {
	Server string
}

func New

func New(server string) (*KongoJWT, error)

func (*KongoJWT) GetToken

func (kongojwt *KongoJWT) GetToken(username string, customID string) (string, error)

GetUserFromToken returns JWT token from an username and a custom ID.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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