Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultErrorHandler(ctx *Context, err error)
- type AuthHandler
- type AuthentifierFactory
- type AuthorizerFactory
- type ClientLoaderFactory
- type Context
- type DecryptHandler
- type ErrorHandler
- type Handler
- type HandlerFunc
- type Middleware
- type Response
- type Server
- type ServerOption
- type SyncHandler
- type VerifyHandler
Constants ¶
const ( // HeaderContent is constant extracted value of Content-Type header HeaderContent = "Content-Type" // HeaderAccept is constant extracted value of Accept header HeaderAccept = "Accept" // MimeText is constant extracted value of mimetype for text MimeText = "text/plain" // MimeJSON is constant extracted value of mimetype for text MimeJSON = "application/json" // FmtErr is yubico format for text error response FmtErr = "ERR %s" )
Variables ¶
var ( // ErrSkip is the error used to notify that error has been handled ErrSkip = fmt.Errorf("error already handled") )
Functions ¶
func DefaultErrorHandler ¶
DefaultErrorHandler is the default way of dealing with error in Yubistack. It maps error returned by the caller in Yubico text equivalent responses
Types ¶
type AuthHandler ¶
type AuthHandler struct { AuthentifierFactory AuthorizerFactory }
AuthHandler is a structure embedding authentication and authorization and serving it as http
func NewAuthHandler ¶
func NewAuthHandler(options ...func(handler *AuthHandler)) *AuthHandler
NewAuthHandler creates a new AuthHandler with sensible defaults
func (*AuthHandler) Handle ¶
func (ah *AuthHandler) Handle(ctx *Context) error
Handle implements the pkg.Handle interface and perform authenticate and authorize over http.
type AuthentifierFactory ¶
type AuthentifierFactory func(zerolog.Logger) ykauth.Authentifier
AuthentifierFactory is currying an Authentifier to inject a logger on each request
type AuthorizerFactory ¶
type AuthorizerFactory func(zerolog.Logger) ykauth.Authorizer
AuthorizerFactory is currying an Authorizer to inject a logger on each request
type ClientLoaderFactory ¶
type ClientLoaderFactory func(zerolog.Logger) yubico.ClientLoader
ClientLoaderFactory is currying a ClientLodaer to inject a logger on each request
type Context ¶
Context wraps most of the structures we want to pass down to the Handler It contains the stdlib ServeHTTP arguments: Request, Response and is enhanced with other services, for the moment only the Logger, but some may be added later (like DB or so).
func (*Context) RemoteHost ¶
RemoteHost get the value of the host without the port
type DecryptHandler ¶
type DecryptHandler struct {
ykksm.DecrypterFactory
}
DecryptHandler is a structure embedding a DecrypterFactory and serving it as http
func NewDecryptHandler ¶
func NewDecryptHandler(options ...func(handler *DecryptHandler)) *DecryptHandler
NewDecryptHandler creates a new DecryptHandler with sensible defaults
func (*DecryptHandler) Handle ¶
func (dh *DecryptHandler) Handle(ctx *Context) error
Handle implements the pkg.Handle interface and decrypt a token over http.
type ErrorHandler ¶
ErrorHandler is the function type we will use to customize error handling
type HandlerFunc ¶
HandlerFunc is a wrapper for a function to implement the Handler interface
func (HandlerFunc) Handle ¶
func (hf HandlerFunc) Handle(ctx *Context) error
Handle wraps a function to implement Handler interface
type Middleware ¶
type Middleware func(HandlerFunc) HandlerFunc
Middleware is the function type we will use to chain middleware in the application
type Response ¶
type Response struct { Code int Header http.Header *bytes.Buffer // contains filtered or unexported fields }
Response wraps the stdlib ResponseWriter interface. It allows to keep some states before writing them to the underlying ResponseWriter where this information can't be retrieved once pushed. The state is pushed by the Context.write() function which is not accessible through the public API.
func NewResponse ¶
func NewResponse(w http.ResponseWriter) *Response
NewResponse creates a new instance of a response with default OK state
type Server ¶
type Server struct { *http.Server zerolog.Logger ErrorHandler // contains filtered or unexported fields }
Server wraps the serving logic
func NewServer ¶
func NewServer(options ...ServerOption) *Server
NewServer creates an instance of a server using option parameters to configure.
func (*Server) HandleFunc ¶
func (s *Server) HandleFunc(path string, handle HandlerFunc)
HandleFunc add a handler function to a specific path
func (*Server) ListenAndServe ¶
ListenAndServe starts a server on the configured addressed over TCP
func (*Server) Serve ¶
Serve starts a server on the given network and address and route request to handlers
func (*Server) Use ¶
func (s *Server) Use(middlewares ...Middleware)
Use plugs a middleware in the request handling chain
type ServerOption ¶
type ServerOption func(*Server)
ServerOption is the function type used to customize the Server fields at creation
func WithTLS ¶
func WithTLS(certFile, keyFile string) ServerOption
WithTLS creates a ServerOption setting up TLS options
type SyncHandler ¶
type SyncHandler struct { ykval.SynchronizerFactory ClientLoaderFactory }
SyncHandler is a structure embedding a SynchronizerFactory and serving it as http
func NewSyncHandler ¶
func NewSyncHandler(options ...func(handler *SyncHandler)) *SyncHandler
NewSyncHandler creates a new SyncHandler with sensible defaults
func (*SyncHandler) Handle ¶
func (sh *SyncHandler) Handle(ctx *Context) error
Handle implements the pkg.Handle interface and synchronize a token over http.
type VerifyHandler ¶
type VerifyHandler struct { ykval.VerifierFactory ClientLoaderFactory }
VerifyHandler is a http.Handler responsible for the verification of tokens
func NewVerifyHandler ¶
func NewVerifyHandler(options ...func(handler *VerifyHandler)) *VerifyHandler
NewVerifyHandler creates a new VerifyHandler with sensible defaults
func (*VerifyHandler) Handle ¶
func (vh *VerifyHandler) Handle(ctx *Context) error
Handle implements the pkg.Handle interface and verify a token over http.