jwtperm

package
v0.13.3 Latest Latest
Warning

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

Go to latest
Published: May 14, 2022 License: LGPL-3.0 Imports: 17 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")
	ErrInvalidCookie = errors.New("invalid cookie")
	ErrExpiredToken  = errors.New("expired or invalid refresh token")
)

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 if it contains a valid cookie.

func (*Checker) Set added in v0.7.1

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

Set puts a HttpOnly cookie when no valid cookie is present in the HTTP response header. The permission conveyied by te cookie is also put in the request context.

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 "Authorization" header.

type Perm

type Perm struct {
	Value int
}

func FromCtx added in v0.13.0

func FromCtx(r *http.Request) Perm

FromCtx gets the permission information from the request context.

Jump to

Keyboard shortcuts

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