Documentation
¶
Overview ¶
Package sessions manages authenticated sessions for HTTP providers that require it. It handles session cookies, authentication tokens, and other state required to make authenticated requests to the provider.
Index ¶
- Variables
- type ErrCookieNotFound
- type Session
- type SessionManager
- func (m SessionManager) GetSession(domain, challengeURL string, forceRefresh bool) (Session, error)
- func (m *SessionManager) WithCacheDir(cacheDir string) *SessionManager
- func (m *SessionManager) WithMustHaveCookies(domain string, cookieNames ...string) *SessionManager
- func (m *SessionManager) WithSessionTTL(sessionTTL time.Duration) *SessionManager
- func (m *SessionManager) WithWaitDuration(waitDuration time.Duration) *SessionManager
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrDomainSessionNotFound = errors.New("session for domain not found")
Functions ¶
This section is empty.
Types ¶
type ErrCookieNotFound ¶
type ErrCookieNotFound struct {
CookieName string
}
func (ErrCookieNotFound) Error ¶
func (e ErrCookieNotFound) Error() string
type SessionManager ¶
type SessionManager struct {
// Directory where the sessions should be stored or are currently stored
CacheDir string
// After how long should saved sessions be considered expired and hence force refresh
SessionTTL time.Duration
// Cookies that must exist in session for domains
MustHaveCookies map[string][]string
// Time to wait for clearance cookies if any
WaitDuration time.Duration
}
func NewSessionManager ¶
func NewSessionManager() *SessionManager
func (SessionManager) GetSession ¶
func (m SessionManager) GetSession(domain, challengeURL string, forceRefresh bool) (Session, error)
GetSession returns a session for the specified domain. challengeURL specifies the full URL of the page containing any challenge that must be completed to obtain valid session cookies. If challengeURL is empty, it defaults to "https://<domain>".
func (*SessionManager) WithCacheDir ¶
func (m *SessionManager) WithCacheDir(cacheDir string) *SessionManager
func (*SessionManager) WithMustHaveCookies ¶
func (m *SessionManager) WithMustHaveCookies(domain string, cookieNames ...string) *SessionManager
func (*SessionManager) WithSessionTTL ¶
func (m *SessionManager) WithSessionTTL(sessionTTL time.Duration) *SessionManager
func (*SessionManager) WithWaitDuration ¶
func (m *SessionManager) WithWaitDuration(waitDuration time.Duration) *SessionManager
Click to show internal directories.
Click to hide internal directories.