jwt

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2023 License: Apache-2.0 Imports: 16 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPrivKeyInvalid = errors.New("invalid private key")
	ErrNoPrivKeyFound = errors.New("no private key found")
)
View Source
var (
	ErrJWTInvalidClaims = echo.NewHTTPError(http.StatusUnauthorized, "invalid jwt claims")
)

Errors.

Functions

func LoadOrCreateIdentityPrivateKey

func LoadOrCreateIdentityPrivateKey(identityFilePath string, identityPrivKey string) (ed25519.PrivateKey, bool, error)

LoadOrCreateIdentityPrivateKey loads an existing Ed25519 based identity private key or creates a new one and stores it as a PEM file in the identityFilePath.

func ParseEd25519PrivateKeyFromString

func ParseEd25519PrivateKeyFromString(identityPrivKey string) (ed25519.PrivateKey, error)

ParseEd25519PrivateKeyFromString parses an Ed25519 private key from a hex encoded string.

func ReadEd25519PrivateKeyFromPEMFile

func ReadEd25519PrivateKeyFromPEMFile(filepath string) (ed25519.PrivateKey, error)

ReadEd25519PrivateKeyFromPEMFile reads an Ed25519 private key from a file with PEM format.

func WriteEd25519PrivateKeyToPEMFile

func WriteEd25519PrivateKeyToPEMFile(filepath string, privateKey ed25519.PrivateKey) error

WriteEd25519PrivateKeyToPEMFile stores an Ed25519 private key to a file with PEM format.

Types

type Auth added in v1.0.0

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

func NewAuth added in v1.0.0

func NewAuth(subject string, sessionTimeout time.Duration, identity string, secret ed25519.PrivateKey) (*Auth, error)

func (*Auth) IssueJWT added in v1.0.0

func (j *Auth) IssueJWT() (string, error)

func (*Auth) Middleware added in v1.0.0

func (j *Auth) Middleware(skipper middleware.Skipper, allow func(c echo.Context, subject string, claims *AuthClaims) bool) echo.MiddlewareFunc

func (*Auth) VerifyJWT added in v1.0.0

func (j *Auth) VerifyJWT(token string, allow func(claims *AuthClaims) bool) bool

type AuthClaims

type AuthClaims struct {
	jwt.StandardClaims
}

func (*AuthClaims) VerifySubject

func (c *AuthClaims) VerifySubject(expected string) bool

Jump to

Keyboard shortcuts

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