Documentation ¶
Overview ¶
Package auth provides a stream processing pattern to supply user authentication to a filu application
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthenticatedUser ¶
An AuthenticatedUser is the result of a correct Username & Password combonation.
type CreatedUser ¶
A CreatedUser is the result of a Request where the user doesn't already exist.
type InvalidPassword ¶
An InvalidPassword is the result of a Request with an invalid password.
type Processor ¶
type Processor interface { RequestConsumer ResultProducer // contains filtered or unexported methods }
A Processor is the step in a Stream when a Request is transformed into a Result. This is where a Username/Password pair would be compared against what exists in a database to determine if the pair is a valid.
type Request ¶
type Request struct { filu.Time Username, Password string // The public interface for the user to receive the // result of the authentication request. InvalidPassword <-chan InvalidPassword CreatedUser <-chan CreatedUser AuthenticatedUser <-chan AuthenticatedUser // contains filtered or unexported fields }
A Request is a filu.Event that represents an authentication request sent by a client/user. It is consumed by a Processor that will output a PostAuthEvent.
func NewRequest ¶
NewRequest will construct a Request suitible for use with Stream.RequestAuthentication() <- Request.
type RequestConsumer ¶
type RequestConsumer interface { // The implementation of Write can assume in will never be called in parallel. Write(Request) }
A RequestConsumer is used as the consumption end of a RequestStream.
type RequestProducer ¶
type RequestProducer interface {
Read() <-chan Request
}
A RequestProducer is used as the production end of a RequestStream.
type RequestStream ¶
type RequestStream interface { RequestConsumer RequestProducer }
A RequestStream represents a function that when given a Request will produce a Request.
func NewRequestStream ¶
func NewRequestStream(streams ...RequestStream) RequestStream
NewRequestStream will concatenate a series of RequestStreams into a single RequestStream. The Consumer entry point will be the first parameter, the Producer endpoint will be the last parameter.
type ResultConsumer ¶
type ResultConsumer interface { // The implementation of Write can assume in will never be called in parallel. Write(Result) }
A ResultConsumer is a sink of a stream of Results.
type ResultProducer ¶
type ResultProducer interface {
Read() <-chan Result
}
A ResultProducer is the source of a stream of Results.
type ResultStream ¶
type ResultStream interface { ResultProducer ResultConsumer }
A ResultStream is sink & source of Results. It is implemented and used when constructing a Stream to hook into the post-auth Result stream for user defined processing.
func NewResultStream ¶
func NewResultStream(streams ...ResultStream) ResultStream
NewResultStream will concatenate a series of ResultStreams into a single ResultStream. The Consumer entry point will be the first parameter, the Producer endpoint will be the last parameter.
type Stream ¶
type Stream interface {
RequestAuthentication() chan<- Request
}
A Stream consumes Request's.
func NewStream ¶
func NewStream(preAuth RequestStream, processor Processor, postAuth ResultStream) Stream
NewStream creates an auth processor and connect the Result output into the provided ResultStream's and returns a terminated Stream that will return the Result of a Request back to the Requestor.