jwtperm

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2022 License: LGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package jwtperm delivers and checks the JWT permissions

Index

Constants

View Source
const (
	HTTP  = "http"
	HTTPS = "https"
)

Variables

View Source
var (
	ErrUnauthorized = errors.New("JWT not authorized")
	ErrNoTokenFound = errors.New("no JWT found")
)

Functions

This section is empty.

Types

type Checker

type Checker struct {
	// contains filtered or unexported fields
}

func New

func New(urls []*url.URL, resErr reserr.ResErr, secretKey []byte, permissions ...interface{}) *Checker

func (*Checker) Chk added in v0.7.1

func (ck *Checker) Chk(next http.Handler) http.Handler

Chk accepts the HTTP request only it contains a valid Cookie.

func (*Checker) Set added in v0.7.1

func (ck *Checker) Set(next http.Handler) http.Handler

Set sets a HttpOnly cookie (if not present and valid) in the HTTP response header.

func (*Checker) Vet added in v0.7.1

func (ck *Checker) Vet(next http.Handler) http.Handler

Vet accepts the HTTP request only if a valid JWT is in the Cookie or in the first "Autorisation" header.

type Perm

type Perm struct {
	Value int
}

func From

func From(r *http.Request) Perm

From gets the permission information from the request context.

type RefreshClaims added in v0.7.0

type RefreshClaims struct {
	Namespace string `json:"n,omitempty"`
	UserName  string `json:"u,omitempty"`
	jwt.RegisteredClaims
}

RefreshClaims is the user refresh token.

Jump to

Keyboard shortcuts

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