Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FormSessionAuthenticator ¶
type FormSessionAuthenticator struct {
// A session store to put validated sessions into
Storage SessionStore
// A TokenExtractor to use to identify the session
// being validated to the SessionStore
Tokener TokenExtractor
// A callback function to use to compare the username
// and password submitted and return true if it's valid,
// or false otherwise. Users of a FormSessionAuthenticator
// are expected to implement this and pass it in the
// constructor. See See examples/SessionValidatorExample
// for an example
ComparisonCallback func(username, password string) bool
}
A FormSessionAuthenticator ties together all of the SessionHand
func (FormSessionAuthenticator) Authenticate ¶
func (s FormSessionAuthenticator) Authenticate(r *http.Request) bool
Implementation of SessionAuthenticator interface. Extracts the username and password form elements, and delegates to the ComparisonCallback which the application provided, storing the session in the SessionStore if it's valid.
type MemorySessionStore ¶
type MemorySessionStore struct {
// contains filtered or unexported fields
}
A MemorySessionStore provides the simplest SessionStore possible. It stores active Tokens to Sessions in memory.
func (MemorySessionStore) AddSession ¶
func (s MemorySessionStore) AddSession(t Token, ses Session) error
func (MemorySessionStore) GetSession ¶
func (s MemorySessionStore) GetSession(t Token) *Session
type Session ¶
type Session struct {
}
A session of a client to the web application. This is expected to eventually support a serializable key/value map
type SessionAuthenticator ¶
A SessionAuthenticator takes an http.Request, and validates whether or not it is authenticated, and should store the Token of an authenticated token into a SessionStore.
See FormSessionAuthenticator for an example which validates Sessions based on the HTML form submission
In the future, new SessionAuthenticators such as a BasicAuth authenticator or a Authorization: Bearer (Oauth, JWT) token authenticator, or a cookie authenticator should also be implemented.
type SessionStore ¶
An interface to something that stores sessions. MemorySessionHandler is the only currently implemented SessionStore, but more persistent stores (ie. a DatabaseSessionStore, or a FilesystemSessionStore) should support this interface.
type Token ¶
type Token string
A Token represents a way to map a request to a session. It can be extracted from an http.Request object by anything that implements the TokenExtractor interface
type TokenExtractor ¶
A TokenExtractor is something that takes a HTTP request object, and extracts a token which can be used by a SessionStore to identify the session making the request.
See the SessionValidatorExample application for an example implementation.
In the future, new TokenExtractors such as a an Authorization: Bearer token extractor, or a cookie token extractor should also be supported.