jwt

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

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

Go to latest
Published: Mar 8, 2016 License: BSD-3-Clause Imports: 5 Imported by: 1

README

JWT Authorization middleware for https://github.com/go-ozzo framework

Look code in example folder for usage or run example

cd example
go get github.com/vvv-v13/ozzo-jwt
go run ozzo_rest_jwt.go

Documentation

Overview

Package auth provides a set of user authentication handlers for the ozzo routing package.

Index

Constants

View Source
const User = "User"

User is the key used to store and retrieve the user identity information in routing.Context

Variables

View Source
var DefaultRealm = "API"

DefaultRealm is the default realm name for HTTP authentication. It is used by HTTP authentication based on Basic and Bearer.

Functions

func CreateToken

func CreateToken(jwtConfig JWTConfig, payload JWTPayload) (string, error)

func JWT

func JWT(fn TokenAuthFunc, jwtConfig JWTConfig, realm ...string) routing.Handler

Types

type Identity

type Identity interface{}

Identity represents an authenticated user. If a user is successfully authenticated by an auth handler (Basic, Bearer, or Query), an Identity object will be made available for injection.

type JWTConfig

type JWTConfig struct {
	Alg     string
	Secret  string
	Expires time.Duration
}

type JWTPayload

type JWTPayload map[string]interface{}

type Payload

type Payload interface{}

type TokenAuthFunc

type TokenAuthFunc func(c *routing.Context, payload JWTPayload) (Payload, error)

TokenAuthFunc is the function for authenticating a user based on a secret token.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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