Documentation ¶
Index ¶
- Variables
- func HandleSetupRequest(request *SetupRequest) (*RequestHandlingState, *SetupResponse, error)
- func ProcessIssuedTokens(response *IssuedTokens) error
- func RegisterPBlindHandler(h *PBlindHandler) error
- func RegisterScrambleHandler(h *ScrambleHandler) error
- func ResetRegistry()
- func VerifyToken(token *Token) error
- type Handler
- type IssuedPBlindTokens
- type IssuedScrambleTokens
- type IssuedTokens
- type PBlindHandler
- func (pbh *PBlindHandler) Amount() int
- func (pbh *PBlindHandler) Clear()
- func (pbh *PBlindHandler) CreateSetup() (state *PBlindSignerState, setupResponse *PBlindSetupResponse, err error)
- func (pbh *PBlindHandler) CreateTokenRequest(requestSetup *PBlindSetupResponse) (request *PBlindTokenRequest, err error)
- func (pbh *PBlindHandler) GetToken() (token *Token, err error)
- func (pbh *PBlindHandler) IsFallback() bool
- func (pbh *PBlindHandler) IssueTokens(state *PBlindSignerState, request *PBlindTokenRequest) (response *IssuedPBlindTokens, err error)
- func (pbh *PBlindHandler) Load(data []byte) error
- func (pbh *PBlindHandler) ProcessIssuedTokens(issuedTokens *IssuedPBlindTokens) error
- func (pbh *PBlindHandler) Save() ([]byte, error)
- func (pbh *PBlindHandler) ShouldRequest() bool
- func (pbh *PBlindHandler) Verify(token *Token) error
- func (pbh *PBlindHandler) Zone() string
- type PBlindOptions
- type PBlindSetupResponse
- type PBlindSignerState
- type PBlindStorage
- type PBlindToken
- type PBlindTokenRequest
- type RequestHandlingState
- type RequestState
- type ScrambleHandler
- func (sh *ScrambleHandler) Amount() int
- func (sh *ScrambleHandler) Clear()
- func (sh *ScrambleHandler) CreateTokenRequest() (request *ScrambleTokenRequest)
- func (sh *ScrambleHandler) GetToken() (*Token, error)
- func (sh *ScrambleHandler) IsFallback() bool
- func (sh *ScrambleHandler) IssueTokens(request *ScrambleTokenRequest) (response *IssuedScrambleTokens, err error)
- func (sh *ScrambleHandler) Load(data []byte) error
- func (sh *ScrambleHandler) ProcessIssuedTokens(issuedTokens *IssuedScrambleTokens) error
- func (sh *ScrambleHandler) Save() ([]byte, error)
- func (sh *ScrambleHandler) ShouldRequest() bool
- func (sh *ScrambleHandler) Verify(token *Token) error
- func (sh *ScrambleHandler) Zone() string
- type ScrambleOptions
- type ScrambleStorage
- type ScrambleToken
- type ScrambleTokenRequest
- type SetupRequest
- type SetupResponse
- type Token
- type TokenRequest
Constants ¶
This section is empty.
Variables ¶
var ( ErrEmpty = errors.New("token storage is empty") ErrNoZone = errors.New("no zone specified") ErrTokenInvalid = errors.New("token is invalid") ErrTokenMalformed = errors.New("token malformed") ErrTokenUsed = errors.New("token already used") ErrZoneMismatch = errors.New("zone mismatch") ErrZoneTaken = errors.New("zone taken") ErrZoneUnknown = errors.New("zone unknown") )
Functions ¶
func HandleSetupRequest ¶
func HandleSetupRequest(request *SetupRequest) (*RequestHandlingState, *SetupResponse, error)
func ProcessIssuedTokens ¶
func ProcessIssuedTokens(response *IssuedTokens) error
func RegisterPBlindHandler ¶
func RegisterPBlindHandler(h *PBlindHandler) error
func RegisterScrambleHandler ¶
func RegisterScrambleHandler(h *ScrambleHandler) error
func ResetRegistry ¶
func ResetRegistry()
func VerifyToken ¶
Types ¶
type Handler ¶
type Handler interface { // Zone returns the zone name. Zone() string // ShouldRequest returns whether the new tokens should be requested. ShouldRequest() bool // Amount returns the current amount of tokens in this handler. Amount() int // IsFallback returns whether this handler should only be used as a fallback. IsFallback() bool // GetToken returns a token. GetToken() (token *Token, err error) // Verify verifies the given token. Verify(token *Token) error // Save serializes and returns the current tokens. Save() ([]byte, error) // Load loads the given tokens into the handler. Load(data []byte) error // Clear clears all the tokens in the handler. Clear() }
Handler represents a token handling system.
func GetHandler ¶
type IssuedPBlindTokens ¶
type IssuedScrambleTokens ¶
type IssuedScrambleTokens struct {
Tokens []*ScrambleToken
}
type IssuedTokens ¶
type IssuedTokens struct { PBlind map[string]*IssuedPBlindTokens `json:"PB,omitempty"` Scramble map[string]*IssuedScrambleTokens `json:"SC,omitempty"` }
func IssueTokens ¶
func IssueTokens(state *RequestHandlingState, request *TokenRequest) (response *IssuedTokens, err error)
type PBlindHandler ¶
type PBlindHandler struct { sync.Mutex Storage []*PBlindToken // contains filtered or unexported fields }
func NewPBlindHandler ¶
func NewPBlindHandler(opts PBlindOptions) (*PBlindHandler, error)
func (*PBlindHandler) Amount ¶
func (pbh *PBlindHandler) Amount() int
Amount returns the current amount of tokens in this handler.
func (*PBlindHandler) Clear ¶ added in v0.3.9
func (pbh *PBlindHandler) Clear()
Clear clears all the tokens in the handler.
func (*PBlindHandler) CreateSetup ¶
func (pbh *PBlindHandler) CreateSetup() (state *PBlindSignerState, setupResponse *PBlindSetupResponse, err error)
CreateSetup sets up signers for a request.
func (*PBlindHandler) CreateTokenRequest ¶
func (pbh *PBlindHandler) CreateTokenRequest(requestSetup *PBlindSetupResponse) (request *PBlindTokenRequest, err error)
CreateTokenRequest creates a token request to be sent to the token server.
func (*PBlindHandler) GetToken ¶
func (pbh *PBlindHandler) GetToken() (token *Token, err error)
GetToken returns a token.
func (*PBlindHandler) IsFallback ¶
func (pbh *PBlindHandler) IsFallback() bool
IsFallback returns whether this handler should only be used as a fallback.
func (*PBlindHandler) IssueTokens ¶
func (pbh *PBlindHandler) IssueTokens(state *PBlindSignerState, request *PBlindTokenRequest) (response *IssuedPBlindTokens, err error)
IssueTokens sign the requested tokens.
func (*PBlindHandler) Load ¶
func (pbh *PBlindHandler) Load(data []byte) error
Load loads the given tokens into the handler.
func (*PBlindHandler) ProcessIssuedTokens ¶
func (pbh *PBlindHandler) ProcessIssuedTokens(issuedTokens *IssuedPBlindTokens) error
ProcessIssuedTokens processes the issued token from the server.
func (*PBlindHandler) Save ¶
func (pbh *PBlindHandler) Save() ([]byte, error)
Save serializes and returns the current tokens.
func (*PBlindHandler) ShouldRequest ¶
func (pbh *PBlindHandler) ShouldRequest() bool
ShouldRequest returns whether the new tokens should be requested.
func (*PBlindHandler) Verify ¶
func (pbh *PBlindHandler) Verify(token *Token) error
Verify verifies the given token.
type PBlindOptions ¶
type PBlindSetupResponse ¶
type PBlindSignerState ¶
type PBlindSignerState struct {
// contains filtered or unexported fields
}
type PBlindStorage ¶
type PBlindStorage struct {
Storage []*PBlindToken
}
type PBlindToken ¶
type PBlindToken struct { Serial int `json:"N,omitempty"` Token []byte `json:"T,omitempty"` Signature *pblind.Signature `json:"S,omitempty"` }
func UnpackPBlindToken ¶
func UnpackPBlindToken(token []byte) (*PBlindToken, error)
func (*PBlindToken) Pack ¶
func (pbt *PBlindToken) Pack() ([]byte, error)
type PBlindTokenRequest ¶
type RequestHandlingState ¶
type RequestHandlingState struct { SessionID string PBlind map[string]*PBlindSignerState }
type RequestState ¶
type RequestState struct { Token []byte State *pblind.StateRequester }
type ScrambleHandler ¶
type ScrambleHandler struct { sync.Mutex Storage []*ScrambleToken // contains filtered or unexported fields }
func NewScrambleHandler ¶
func NewScrambleHandler(opts ScrambleOptions) (*ScrambleHandler, error)
func (*ScrambleHandler) Amount ¶
func (sh *ScrambleHandler) Amount() int
Amount returns the current amount of tokens in this handler.
func (*ScrambleHandler) Clear ¶ added in v0.3.9
func (sh *ScrambleHandler) Clear()
Clear clears all the tokens in the handler.
func (*ScrambleHandler) CreateTokenRequest ¶
func (sh *ScrambleHandler) CreateTokenRequest() (request *ScrambleTokenRequest)
CreateTokenRequest creates a token request to be sent to the token server.
func (*ScrambleHandler) GetToken ¶
func (sh *ScrambleHandler) GetToken() (*Token, error)
GetToken returns a token.
func (*ScrambleHandler) IsFallback ¶
func (sh *ScrambleHandler) IsFallback() bool
IsFallback returns whether this handler should only be used as a fallback.
func (*ScrambleHandler) IssueTokens ¶
func (sh *ScrambleHandler) IssueTokens(request *ScrambleTokenRequest) (response *IssuedScrambleTokens, err error)
IssueTokens sign the requested tokens.
func (*ScrambleHandler) Load ¶
func (sh *ScrambleHandler) Load(data []byte) error
Load loads the given tokens into the handler.
func (*ScrambleHandler) ProcessIssuedTokens ¶
func (sh *ScrambleHandler) ProcessIssuedTokens(issuedTokens *IssuedScrambleTokens) error
ProcessIssuedTokens processes the issued token from the server.
func (*ScrambleHandler) Save ¶
func (sh *ScrambleHandler) Save() ([]byte, error)
Save serializes and returns the current tokens.
func (*ScrambleHandler) ShouldRequest ¶
func (sh *ScrambleHandler) ShouldRequest() bool
ShouldRequest returns whether the new tokens should be requested.
func (*ScrambleHandler) Verify ¶
func (sh *ScrambleHandler) Verify(token *Token) error
Verify verifies the given token.
type ScrambleOptions ¶
type ScrambleStorage ¶
type ScrambleStorage struct {
Storage []*ScrambleToken
}
type ScrambleToken ¶
type ScrambleToken struct {
Token []byte
}
func UnpackScrambleToken ¶
func UnpackScrambleToken(token []byte) (*ScrambleToken, error)
func (*ScrambleToken) Pack ¶
func (pbt *ScrambleToken) Pack() ([]byte, error)
type ScrambleTokenRequest ¶
type ScrambleTokenRequest struct { }
type SetupRequest ¶
type SetupRequest struct {
PBlind map[string]struct{} `json:"PB,omitempty"`
}
func CreateSetupRequest ¶
func CreateSetupRequest() (request *SetupRequest, setupRequired bool)
type SetupResponse ¶
type SetupResponse struct { SessionID string `json:"ID,omitempty"` PBlind map[string]*PBlindSetupResponse `json:"PB,omitempty"` }
type TokenRequest ¶
type TokenRequest struct { SessionID string `json:"ID,omitempty"` PBlind map[string]*PBlindTokenRequest `json:"PB,omitempty"` Scramble map[string]*ScrambleTokenRequest `json:"S,omitempty"` }
func CreateTokenRequest ¶
func CreateTokenRequest(setup *SetupResponse) (request *TokenRequest, requestRequired bool, err error)