client

package
v0.0.0-...-12d1dba Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2014 License: LGPL-3.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const AuthDirName = "auth"
View Source
const AuthTokenSuffix = ".token"

Variables

View Source
var ErrAuthNotFound error = fmt.Errorf("authorization not found")

Functions

func WantsAuth

func WantsAuth(resp *http.Response) []*affinity.TokenInfo

WantsAuth returns information on the authentication schemes a server is advertising. These are mandatory for an HTTP 401 Not Authorized response, but may also be given in other responses.

Types

type AuthClient

type AuthClient struct {
	*http.Client
	Store AuthStore
}

AuthClient is an *http.Client that is able to automatically negotiate authentication with a server from an AuthStore.

func (*AuthClient) Authorize

func (c *AuthClient) Authorize(req *http.Request, schemes []*affinity.TokenInfo) error

Authorize adds any stored auth tokens from the requested schemes to an *http.Request.

func (*AuthClient) Do

func (c *AuthClient) Do(req *http.Request) (resp *http.Response, err error)

Do performs an *http.Request and returns the *http.Response or any error that occurs, after automatically attempting to negotiate authentication with the server.

type AuthStore

type AuthStore interface {
	// Get reads and decodes the authentication token from storage.
	Get(scheme string, endpoint string) (*affinity.TokenInfo, error)
	// Set stores an authentication token.
	Set(token *affinity.TokenInfo, endpoint string) error
}

AuthTokenStore stores authentication tokens by their scheme and endpoint.

type FileAuthStore

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

FileAuthStore stores an affinity client's authentication credential in a directory structure with file naming convention.

func NewFileAuthStore

func NewFileAuthStore(baseDir string) (*FileAuthStore, error)

NewFileAuthStore creates a new FileAuthStore at the given directory.

func (*FileAuthStore) Get

func (s *FileAuthStore) Get(scheme string, endpoint string) (*affinity.TokenInfo, error)

Get retrieves a token for a scheme and endpoint.

func (*FileAuthStore) Set

func (s *FileAuthStore) Set(token *affinity.TokenInfo, endpoint string) error

Set stores a token.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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