token

package
v0.0.0-...-e067ed2 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2015 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateKeypair

func GenerateKeypair(filename string) (err error)

GenerateKeypair generates a public and private ECDSA key, for later user with NewIssuer or NewVerifier. These are written as binary files, because PEM is pointless.

Types

type Issuer

type Issuer struct {
	Verifier

	// LogTokenIssued is an optional user-provided function to log each
	// token that is issued. If nil, no logging is performed. It
	// should not panic; if it returns an error, the token is not
	// return to the caller of Issue.
	LogTokenIssued func(signedToken []byte, unsignedToken *pb.Token) error
	// contains filtered or unexported fields
}

Issuer represents an issuer of tokens under a particular public key.

func NewIssuer

func NewIssuer(filename string) (iss *Issuer, err error)

NewIssuer is, for the moment, a thin wrapper around Square's go-jose library to issue ECDSA-P256 JWS tokens.

func (*Issuer) Issue

func (iss *Issuer) Issue(token *pb.Token) (signed string, err error)

Issue issues a new, signed token, logging it to iss.LogToken if that's non-nil.

type Verifier

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

Verifier represents an object that can verify tokens.

func NewVerifier

func NewVerifier(basename string) (v *Verifier, err error)

NewVerify reads a verification key file, and returns a verifier to verify token objects.

func (*Verifier) Verify

func (v *Verifier) Verify(s string) (token *pb.Token, err error)

Verify checks that a token's signature is valid, and that the protobuf is syntactically valid as a token.

Directories

Path Synopsis
The pb package contains the definitions of the proto3 structures used for representing tokens.
The pb package contains the definitions of the proto3 structures used for representing tokens.

Jump to

Keyboard shortcuts

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