Documentation ¶
Index ¶
- Constants
- Variables
- type Config
- type Identity
- type Kind
- type Role
- type Store
- func (x *Store) DeleteSession(ctx context.Context, id string) error
- func (x *Store) DeleteSessionFromRequest(ctx context.Context, r *http.Request) error
- func (x *Store) GetSession(ctx context.Context, id string, dest *Identity) error
- func (x *Store) NewCookie(ctx context.Context, src *Identity, expires time.Duration) (*http.Cookie, error)
- func (x *Store) NewSession(ctx context.Context, src *Identity, expires time.Duration) (string, error)
- func (x *Store) ReadSessionFromRequest(ctx context.Context, r *http.Request, dest *Identity) error
Constants ¶
const DataFile = "users.json"
Variables ¶
var ErrSessionNotFound = errors.New("session not found")
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // CookieName is the name of the cookies created by the store. CookieName string `split_words:"true" default:"vvgo-sessions"` // CookieDomain is the domain where the cookies can be used. // This should be the domain that users visit in their browser. CookieDomain string `split_words:"true" default:"localhost"` // CookiePath is the url path where the cookies can be used. CookiePath string `split_words:"true" default:"/"` }
type Identity ¶
A user identity. This _absolutely_ should not contain any personally identifiable information. Numeric user id's are fine, but no emails, user names, addresses, etc.
func (Identity) IsAnonymous ¶
type Kind ¶
type Kind string
The kind of login This can be used to access additional metadata fields we might add for a particular login.
type Role ¶
type Role string
A user role. Users can have multiple roles. These provide different levels of access to the api.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store provides access to the map of session id's to access roles. It can read and validate session cookies from incoming requests,
func (*Store) DeleteSession ¶
DeleteSession deletes the sessionID key from redis.
func (*Store) DeleteSessionFromRequest ¶
func (*Store) GetSession ¶
GetSession reads the login identity for the given session ID.
func (*Store) NewCookie ¶
func (x *Store) NewCookie(ctx context.Context, src *Identity, expires time.Duration) (*http.Cookie, error)
NewCookie returns cookie with a crypto-rand session id.