paseto

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 14 Imported by: 0

README

paseto

build-img pkg-img reportcard-img coverage-img version-img

PASETO (Platform-Agnostic Security Tokens implementation) in Go paseto.

See also JWT in Go cristalhq/jwt.

Features

  • Simple API.
  • Clean and tested code.
  • Optimized for speed.
  • Concurrent-safe.

See docs or GUIDE.md for more details.

Install

Go version 1.21+

go get github.com/cristalhq/paseto

Example

// TODO

See examples: example_test.go.

License

MIT License.

Documentation

Overview

Example
package main

import ()

func main() {
}
Output:

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	ErrDataUnmarshal        = errors.New("can't unmarshal token data to the given type of value")
	ErrInvalidTokenAuth     = errors.New("invalid token authentication")
	ErrIncorrectTokenFormat = errors.New("incorrect token format")
	ErrIncorrectTokenHeader = errors.New("incorrect token header")
)

Functions

func V1Decrypt

func V1Decrypt(token string, key []byte, payload, footer any) error

func V1Encrypt

func V1Encrypt(key []byte, payload, footer any, randBytes []byte) (string, error)

Types

type Token

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

func (*Token) Bytes

func (t *Token) Bytes() []byte

func (*Token) Claims

func (t *Token) Claims() json.RawMessage

Claims returns token's claims.

func (*Token) ClaimsPart

func (t *Token) ClaimsPart() []byte

ClaimsPart returns token claims part.

func (*Token) DecodeClaims

func (t *Token) DecodeClaims(dst any) error

DecodeClaims into a given parameter.

func (*Token) DecodeFooter

func (t *Token) DecodeFooter(dst any) error

DecodeFooter into a given parameter.

func (*Token) Footer

func (t *Token) Footer() json.RawMessage

Footer returns token's footer.

func (*Token) HeaderPart

func (t *Token) HeaderPart() []byte

HeaderPart returns token header part.

func (*Token) PayloadPart

func (t *Token) PayloadPart() []byte

PayloadPart returns token payload part.

func (*Token) SignaturePart

func (t *Token) SignaturePart() []byte

SignaturePart returns token signature part.

func (*Token) String

func (t *Token) String() string

func (Token) Type

func (t Token) Type() TokenType

type TokenType

type TokenType uint
const (
	TokenUnknown  TokenType = 0
	TokenV1Local  TokenType = 1
	TokenV1Public TokenType = 2
	TokenV2Local  TokenType = 3
	TokenV2Public TokenType = 4
	TokenV3Local  TokenType = 5
	TokenV3Public TokenType = 6
	TokenV4Local  TokenType = 7
	TokenV4Public TokenType = 8
)

Jump to

Keyboard shortcuts

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