auth

package
v1.0.4-4 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2015 License: BSD-3-Clause, BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Code used to support authentication tokens for arbitrary purposes.

Index

Constants

View Source
const (
	TokenType           = "auth"
	CurrentTokenVersion = 1
)

Variables

View Source
var ErrCanceled = errors.New("canceled")

ErrCanceled is raised when an API operation is canceled midstream.

View Source
var ErrShutdown = errors.New("shutting down")

ErrShutdown is raised when an operation is pending but the CA is shutting down

Functions

This section is empty.

Types

type BadKeyError

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

BadKeyError is raised when the given KID is not valid for the given UID.

func (BadKeyError) Error

func (e BadKeyError) Error() string

type BadUsernameError

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

BadUsernameError is raised when the given username disagreeds with the expected username

func (BadUsernameError) Error

func (e BadUsernameError) Error() string

type CredentialAuthority

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

CredentialAuthority should be allocated as a singleton object. It validates UID<->Username<->ActiveKey triples for all users across a service. It keeps a cache and subscribes for updates, so you can call into it as much as you'd like without fear of spamming the network.

func NewCredentialAuthority

func NewCredentialAuthority(log logger.Logger, api UserKeyAPIer) *CredentialAuthority

NewCredentialAuthority makes a new signleton CredentialAuthority an start it running. It takes as input a logger and an API for making keybase API calls

func (*CredentialAuthority) Check

func (v *CredentialAuthority) Check(ctx context.Context, uid keybase1.UID, username libkb.NormalizedUsername, kid keybase1.KID) (err error)

Check is the main point of entry to this library. It takes as input a UID, a username and a kid that should refer to a current valid triple, perhaps extracted from a signed authentication statement. It returns an error if the check fails, and nil otherwise.

func (*CredentialAuthority) Shutdown

func (v *CredentialAuthority) Shutdown()

Shutdown the credentialAuthority and delete all internal state.

type InvalidTokenKeyError

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

InvalidTokenKeyError is raised then the public key presented in the token does not correspond to the private key used to sign the token.

func (InvalidTokenKeyError) Error

func (e InvalidTokenKeyError) Error() string

type InvalidTokenServerError

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

InvalidTokenServerError is raised then the server presented in the token does not correspond to the server being asked to verify the token.

func (InvalidTokenServerError) Error

func (e InvalidTokenServerError) Error() string

type InvalidTokenTypeError

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

InvalidTokenTypeError is raised when the given token is not of the expected type.

func (InvalidTokenTypeError) Error

func (e InvalidTokenTypeError) Error() string

type MaxTokenExpiresError

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

MaxTokenExpiresError is raised when the given token expires too far in the future.

func (MaxTokenExpiresError) Error

func (e MaxTokenExpiresError) Error() string

type Token

type Token struct {
	Body         TokenBody   `json:"body"`
	Client       TokenClient `json:"client"`
	CreationTime int64       `json:"ctime"`
	ExpireIn     int         `json:"expire_in"`
	Tag          string      `json:"tag"`
}

func NewToken

func NewToken(uid keybase1.UID, username libkb.NormalizedUsername, kid keybase1.KID,
	server string, expireIn int, clientName string, clientVersion string) *Token

func VerifyToken

func VerifyToken(signature, server string, maxExpireIn int) (*Token, error)

func (Token) Bytes

func (t Token) Bytes() []byte

func (Token) ClientName

func (t Token) ClientName() string

func (Token) ClientVersion

func (t Token) ClientVersion() string

func (Token) KID

func (t Token) KID() keybase1.KID

func (Token) Server

func (t Token) Server() string

func (Token) String

func (t Token) String() string

func (Token) TimeRemaining

func (t Token) TimeRemaining() int

func (Token) Type

func (t Token) Type() string

func (Token) UID

func (t Token) UID() keybase1.UID

func (Token) Username

func (t Token) Username() libkb.NormalizedUsername

func (Token) Version

func (t Token) Version() int

type TokenAuth

type TokenAuth struct {
	Server string `json:"server"`
}

type TokenBody

type TokenBody struct {
	Auth    TokenAuth `json:"auth"`
	Key     TokenKey  `json:"key"`
	Type    string    `json:"type"`
	Version int       `json:"version"`
}

type TokenClient

type TokenClient struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

type TokenExpiredError

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

TokenExpiredError is raised when the given token is expired.

func (TokenExpiredError) Error

func (e TokenExpiredError) Error() string

type TokenKey

type TokenKey struct {
	UID      keybase1.UID             `json:"uid"`
	Username libkb.NormalizedUsername `json:"username"`
	KID      keybase1.KID             `json:"kid"`
}

type UserKeyAPIer

type UserKeyAPIer interface {
	// GetUser looks up the username and KIDS active for the given user.
	GetUser(context.Context, keybase1.UID) (libkb.NormalizedUsername, []keybase1.KID, error)
	// PollForChanges returns the UIDs that have recently changed on the server
	// side. It will be called in a poll loop.
	PollForChanges(context.Context) ([]keybase1.UID, error)
}

UserKeyAPIer is an interface that specifies the UserKeyAPI that will eventually be used to get information about the users from the trusted server authority.

func NewUserKeyAPIer

func NewUserKeyAPIer(log logger.Logger, api libkb.API) UserKeyAPIer

NewUserKeyAPIer returns a UserKeyAPIer implementation.

Jump to

Keyboard shortcuts

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