Documentation
¶
Index ¶
- Constants
- func Module(module common.Module)
- func NewDatabase() (database.Database, common.Closer, error)
- type Service
- type Session
- type SessionRecord
- type SessionRepository
- func (repo *SessionRepository) AssignIdentity(tx *sql.Tx, sessionId string, identityId string, expires time.Time, ...) (*SessionRecord, error)
- func (repo *SessionRepository) DeleteSessionById(tx *sql.Tx, sessionId string) error
- func (repo *SessionRepository) DeleteSessionsByExpiresAfter(tx *sql.Tx, expiration time.Time) error
- func (repo *SessionRepository) DeleteValue(tx *sql.Tx, sessionId string, key string) error
- func (repo *SessionRepository) FindAllSessionValues(tx *sql.Tx, sessionId string) ([]*SessionValueRecord, error)
- func (repo *SessionRepository) FindById(tx *sql.Tx, sessionId string) (*SessionRecord, error)
- func (repo *SessionRepository) GetValue(tx *sql.Tx, sessionId string, key string) (*SessionValueRecord, error)
- func (repo *SessionRepository) NewSession(tx *sql.Tx, expires *time.Time) (*SessionRecord, error)
- func (repo *SessionRepository) SetValue(tx *sql.Tx, sessionId string, key string, value string) (*SessionValueRecord, error)
- func (repo *SessionRepository) UpdateExpiration(tx *sql.Tx, sessionId string, expires time.Time) (*SessionRecord, error)
- type SessionValueRecord
Constants ¶
View Source
const ( SESSION_LIFETIME = 1 * time.Hour GC_PERIOD = 2 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Service ¶
type Service interface {
NewSession(ctx context.Context) (Session, error)
LookupById(ctx context.Context, id *common.Ulid) (Session, error)
Authenticate(session Session, identityId *common.Ulid, credentialId *common.Ulid) (Session, error)
DeleteSession(session Session) error
PutValue(session Session, key string, value fmt.Stringer) error
}
func NewService ¶
func NewService(repo *SessionRepository) (Service, common.ContextValues)
type Session ¶
type Session interface {
context.Context
Id() *common.Ulid
RequestId() *common.Ulid
Expires() *time.Time
ActorId() *common.Ulid
CredentialId() *common.Ulid
// NOTE: This function does not check if a session is expired.
// It only checks for existence of the required authentication fields.
Authenticated() bool
Expired() bool
LocalMemberships() []*common.Ulid
MemberOf(localId *common.Ulid) bool
NewRequest() Session
WithMemberships(locals []*common.Ulid) Session
Values() common.M
// contains filtered or unexported methods
}
func FromContext ¶
type SessionRecord ¶
type SessionRepository ¶
type SessionRepository struct {
// contains filtered or unexported fields
}
func NewRepo ¶
func NewRepo(db database.Database) *SessionRepository
func (*SessionRepository) AssignIdentity ¶
func (repo *SessionRepository) AssignIdentity( tx *sql.Tx, sessionId string, identityId string, expires time.Time, credentialId string, ) (*SessionRecord, error)
func (*SessionRepository) DeleteSessionById ¶
func (repo *SessionRepository) DeleteSessionById( tx *sql.Tx, sessionId string, ) error
func (*SessionRepository) DeleteSessionsByExpiresAfter ¶
func (*SessionRepository) DeleteValue ¶
func (*SessionRepository) FindAllSessionValues ¶
func (repo *SessionRepository) FindAllSessionValues(tx *sql.Tx, sessionId string) ([]*SessionValueRecord, error)
func (*SessionRepository) FindById ¶
func (repo *SessionRepository) FindById(tx *sql.Tx, sessionId string) (*SessionRecord, error)
func (*SessionRepository) GetValue ¶
func (repo *SessionRepository) GetValue( tx *sql.Tx, sessionId string, key string, ) (*SessionValueRecord, error)
func (*SessionRepository) NewSession ¶
func (repo *SessionRepository) NewSession(tx *sql.Tx, expires *time.Time) (*SessionRecord, error)
func (*SessionRepository) SetValue ¶
func (repo *SessionRepository) SetValue( tx *sql.Tx, sessionId string, key string, value string, ) (*SessionValueRecord, error)
func (*SessionRepository) UpdateExpiration ¶
func (repo *SessionRepository) UpdateExpiration( tx *sql.Tx, sessionId string, expires time.Time, ) (*SessionRecord, error)
Click to show internal directories.
Click to hide internal directories.