sessions: github.com/adam-hanna/sessions/auth Index | Files

package auth

import "github.com/adam-hanna/sessions/auth"

Index

Package Files

service.go service_interface.go service_util.go

Variables

var (
    // ErrNoSessionKey is thrown when no key was provided for HMAC signing
    ErrNoSessionKey = errors.New("no session key")
    // ErrMalformedSession is thrown when the session value doesn't conform to expectations
    ErrMalformedSession = errors.New("malformed session")
    // ErrInvalidSession the signature included with the session can't be verified with the provided session key \
    // or is malformed in some way
    ErrInvalidSession = errors.New("invalid session")
)

note @adam-hanna: can these be constants?

var (
    // ErrBase64Encode is thrown when a byte slice could not be base64 encoded
    ErrBase64Encode = errors.New("Base64 encoding failed")
    // ErrBase64Decode is thrown when a byte slice could not be base64 decoded
    ErrBase64Decode = errors.New("Base64 decoding failed")
)

type Options Uses

type Options struct {
    // Key is a slice of bytes for performing HMAC signing and verification operations
    Key []byte
}

Options defines the behavior of the auth service

type Service Uses

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

Service performs signing and verification actions using HMAC

func New Uses

func New(options Options) (*Service, error)

New returns a new auth service

func (*Service) SignAndBase64Encode Uses

func (s *Service) SignAndBase64Encode(sessionID string) (string, error)

SignAndBase64Encode signs the sessionID with the key and returns a base64 encoded string

func (*Service) VerifyAndDecode Uses

func (s *Service) VerifyAndDecode(signed string) (string, error)

VerifyAndDecode takes in a signed session string and returns a sessionID, only if the signed string passes auth verification.

type ServiceInterface Uses

type ServiceInterface interface {
    SignAndBase64Encode(sessionID string) (string, error)
    VerifyAndDecode(signed string) (string, error)
}

ServiceInterface defines the methods that are performend by the auth service

Package auth imports 4 packages (graph) and is imported by 1 packages. Updated 2017-05-07. Refresh now. Tools for package owners.