Documentation
¶
Index ¶
- Constants
- type UserSessionStore
- func (store *UserSessionStore) ClearingCookie(name string) http.Cookie
- func (store *UserSessionStore) Get(r *http.Request, name string) (*sessions.Session, error)
- func (store *UserSessionStore) GetName() string
- func (store *UserSessionStore) MaxAge(age int)
- func (store *UserSessionStore) MaxLength(l int)
- func (store *UserSessionStore) New(r *http.Request, name string) (*sessions.Session, error)
- func (store *UserSessionStore) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) error
- type UserSessionStoreOpt
- func WithCookieAllowInsecure(allow bool) UserSessionStoreOpt
- func WithCookieDomain(domain string) UserSessionStoreOpt
- func WithCookieName(name string) UserSessionStoreOpt
- func WithCookieSecrets(secrets ...string) UserSessionStoreOpt
- func WithLogger(l *zerolog.Logger) UserSessionStoreOpt
- func WithSessionRepository(repo v1.UserSessionRepository) UserSessionStoreOpt
- type UserSessionStoreOpts
Constants ¶
const UserSessionKey string = "user_id"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type UserSessionStore ¶
type UserSessionStore struct {
// contains filtered or unexported fields
}
func NewUserSessionStore ¶
func NewUserSessionStore(fs ...UserSessionStoreOpt) (*UserSessionStore, error)
func (*UserSessionStore) ClearingCookie ¶ added in v0.86.5
func (store *UserSessionStore) ClearingCookie(name string) http.Cookie
ClearingCookie returns an http.Cookie that expires the named session cookie in the browser. Use when the session cannot be loaded but the client may still hold a stale cookie.
The cookie is built via sessions.NewCookie with a copy of the store's Options and MaxAge=-1 so that both MaxAge and Expires (set to a past time by sessions.NewCookie) are populated. Some clients ignore MaxAge and rely solely on Expires for deletion.
func (*UserSessionStore) Get ¶
Get Fetches a session for a given name after it has been added to the registry.
func (*UserSessionStore) GetName ¶
func (store *UserSessionStore) GetName() string
func (*UserSessionStore) MaxAge ¶
func (store *UserSessionStore) MaxAge(age int)
MaxAge sets the maximum age for the store and the underlying cookie implementation. Individual sessions can be deleted by setting Options.MaxAge = -1 for that session.
func (*UserSessionStore) MaxLength ¶
func (store *UserSessionStore) MaxLength(l int)
MaxLength restricts the maximum length of new sessions to l. If l is 0 there is no limit to the size of a session, use with caution. The default for a new PGStore is 4096. PostgreSQL allows for max value sizes of up to 1GB (http://www.postgresql.org/docs/current/interactive/datatype-character.html)
func (*UserSessionStore) Save ¶
func (store *UserSessionStore) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) error
Save saves the given session into the database and deletes cookies if needed
type UserSessionStoreOpt ¶
type UserSessionStoreOpt func(*UserSessionStoreOpts)
func WithCookieAllowInsecure ¶
func WithCookieAllowInsecure(allow bool) UserSessionStoreOpt
func WithCookieDomain ¶
func WithCookieDomain(domain string) UserSessionStoreOpt
func WithCookieName ¶
func WithCookieName(name string) UserSessionStoreOpt
func WithCookieSecrets ¶
func WithCookieSecrets(secrets ...string) UserSessionStoreOpt
func WithLogger ¶ added in v0.86.5
func WithLogger(l *zerolog.Logger) UserSessionStoreOpt
WithLogger sets the zerolog logger used for session-store diagnostics. If unset, logs are discarded.
func WithSessionRepository ¶
func WithSessionRepository(repo v1.UserSessionRepository) UserSessionStoreOpt
type UserSessionStoreOpts ¶
type UserSessionStoreOpts struct {
// contains filtered or unexported fields
}