services

package
v0.0.0-...-4fd71c7 Latest Latest
Warning

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

Go to latest
Published: May 24, 2016 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package services implements services which provides JWK signing and verifying.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	JWK    jwk.Key
	RawKey interface{}
}

A Cache represents the loaded keys by Signer or Verifier service.

type ClaimsSecure

type ClaimsSecure interface {
	GetAudience() string
	GetExpireAt() time.Time
	GetIssuedAt() time.Time
	GetIssuer() string
	GetNotBefore() time.Time
	GetSubject() string

	SetExpireAt(time.Time)
	SetIssuedAt(time.Time)
	SetIssuer(string)
	SetNotBefore(time.Time)

	jwt.Claims
}

A ClaimsSecure represents a JSON object which has a basic set of claims to safely validate it.

type Config

type Config struct {
	Issuer    string
	SetURL    string
	SignKeyID string
	Duration  time.Duration
}

A Config allows to define settings for Signer service.

type ErrInvalidKeyID

type ErrInvalidKeyID string

An ErrInvalidKeyID represents an error when the key identifier used to sign a token could not be found.

func (ErrInvalidKeyID) Error

func (e ErrInvalidKeyID) Error() string

Error returns string representation of current instance error.

type ErrInvalidToken

type ErrInvalidToken int

An ErrInvalidToken represents an error when a token is not valid.

func (ErrInvalidToken) Error

func (e ErrInvalidToken) Error() string

Error returns string representation of current instance error.

type ErrUnexpectedAlg

type ErrUnexpectedAlg string

An ErrUnexpectedAlg represents an error when a token uses an unexpected algorithm for its signature.

func (ErrUnexpectedAlg) Error

func (e ErrUnexpectedAlg) Error() string

Error returns string representation of current instance error.

type Signer

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

A Signer represents a service which provides token creation and signing.

func NewSigner

func NewSigner(adpSet adapters.Set, config Config) (*Signer, error)

NewSigner creates a new instance of Signer service.

func (*Signer) Create

func (s *Signer) Create(payload ClaimsSecure) (string, error)

Create a new token and sign it.

type Verifier

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

A Verifier represents a service which provides token decoding and validation.

func NewVerifier

func NewVerifier(
	svcJWKSet jwkservices.SetService,
	tracer tlog.Tracer,
	issuers ...string,
) (*Verifier, error)

NewVerifier creates a new instance of Verifier service.

func (*Verifier) Verify

func (v *Verifier) Verify(
	rawtoken string,
	header jws.Header,
	payload ClaimsSecure,
) (*jws.SignedToken, error)

Verify specified token and decode it.

Jump to

Keyboard shortcuts

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