jwt

package
v1.0.0-beta.5 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

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 AuthClaims

type AuthClaims struct {
	jwt.StandardClaims
}

func (*AuthClaims) VerifySubject

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

type JWTAuth

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

func NewJWTAuth

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

func (*JWTAuth) IssueJWT

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

func (*JWTAuth) Middleware

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

func (*JWTAuth) VerifyJWT

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

Jump to

Keyboard shortcuts

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