middleware

package
v0.0.0-...-ae0e7a4 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package middleware contains the middleware for the HTTP server

Index

Constants

View Source
const (
	// CookieName is the name of the cookie
	CookieName = "accessToken"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Authenticator

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

Authenticator is a middleware for authenticating requests

func New

func New(logger *zap.Logger, privateKey *rsa.PrivateKey) (*Authenticator, error)

New creates a new Authenticator

func (*Authenticator) Authenticate

func (a *Authenticator) Authenticate(next http.Handler) http.Handler

Authenticate is the middleware function

type Claims

type Claims struct {
	SessionID   string            `json:"session_id"`
	Permissions map[string]string `json:"permissions"`
	jwt.RegisteredClaims
}

Claims is a custom claims type for JWT

type ContextKey

type ContextKey string

ContextKey is a custom type for context keys

var (
	// SessionIDKey is the key for the session ID in the context
	SessionIDKey ContextKey = "session_id"
	// Permissions is the key for the permissions in the context
	Permissions ContextKey = "perms"
)

Jump to

Keyboard shortcuts

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