prototoken

package module
v0.0.0-...-70f5027 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2016 License: MIT Imports: 9 Imported by: 0

README

Build Status Coverage Status GoDoc Go Report Card

ProtoToken

Signed ProtoBuf Messages

This package provides simple methods to sign and verify protobuf messages for use as tokens. It can genererate both string and binary tokens and supports multiple signing mehtods.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractMessage

func ExtractMessage(token *pb.Token, result proto.Message) error

ExtractMessage extracts a tokens value without validation

func GenerateBytes

func GenerateBytes(object proto.Message, key PrivateKey) ([]byte, error)

GenerateBytes generates token bytes

func GenerateString

func GenerateString(object proto.Message, key PrivateKey) (string, error)

GenerateString generates token string

func GenerateToken

func GenerateToken(object proto.Message, key PrivateKey) (*pb.Token, error)

GenerateToken generates a token object

func UnpackBytes

func UnpackBytes(data []byte) (*pb.Token, error)

UnpackBytes unpacks token bytes without validation

func UnpackString

func UnpackString(data string) (*pb.Token, error)

UnpackString unpacks a token string without validation

func ValidateBytes

func ValidateBytes(data []byte, key PublicKey, result proto.Message) (*pb.Token, error)

ValidateBytes validates token bytes

func ValidateString

func ValidateString(data string, key PublicKey, result proto.Message) (*pb.Token, error)

ValidateString validates token string

func ValidateToken

func ValidateToken(token *pb.Token, key PublicKey, result proto.Message) error

ValidateToken validates token object

Types

type PrivateKey

type PrivateKey interface {
	Generate(data []byte) ([]byte, error)
}

PrivateKey is used to sign tokens

func NewHMACPrivateKey

func NewHMACPrivateKey(secret []byte) PrivateKey

NewHMACPrivateKey creates a new private key

func NewRSAPrivateKey

func NewRSAPrivateKey(key *rsa.PrivateKey) PrivateKey

NewRSAPrivateKey creates a private key from an RSA private key

type PublicKey

type PublicKey interface {
	Validate(data []byte, signature []byte) error
}

PublicKey is used to validate tokens

func NewHMACPublicKey

func NewHMACPublicKey(secret []byte) PublicKey

NewHMACPublicKey creates a new public key

func NewRSAPublicKey

func NewRSAPublicKey(key *rsa.PublicKey) PublicKey

NewRSAPublicKey creates a public key from an RSA public key

Directories

Path Synopsis
Package pb is a generated protocol buffer package.
Package pb is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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