Documentation ¶
Overview ¶
Package auth handles the server-side authentication and session management.
Index ¶
- type Credentials
- type SessionInfo
- func (a *SessionInfo) CheckACL(db gorm.DB, objects ...shared.ACL) bool
- func (s *SessionInfo) GetGID() uint
- func (s *SessionInfo) GetName() string
- func (s *SessionInfo) GetUID() uint
- func (s *SessionInfo) IsAdmin() bool
- func (s *SessionInfo) IsSuper() bool
- func (s *SessionInfo) NextKey() crypto.Binary
- type SessionPool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Credentials ¶
type Credentials interface { GetName() string GetUID() uint GetGID() uint GetPass() crypto.Binary IsAdmin() bool }
Credentials is a generic interface to return the stored credentials for a user.
type SessionInfo ¶
type SessionInfo struct { Name string UID uint GID uint Admin bool Super bool SessionKey crypto.Binary SessionTime time.Time // contains filtered or unexported fields }
SessionInfo holds the details of the user of a session.
func Auth ¶
func Auth(creds Credentials, pass []byte) (ok bool, sess *SessionInfo)
Auth verifies a password avainst a credentials object.
func (*SessionInfo) CheckACL ¶
CheckACL runs the lookup function of the specified object(s) and returns true only if the user has access to all objects specified.
func (*SessionInfo) GetGID ¶
func (s *SessionInfo) GetGID() uint
func (*SessionInfo) GetName ¶
func (s *SessionInfo) GetName() string
func (*SessionInfo) GetUID ¶
func (s *SessionInfo) GetUID() uint
func (*SessionInfo) IsAdmin ¶
func (s *SessionInfo) IsAdmin() bool
func (*SessionInfo) IsSuper ¶
func (s *SessionInfo) IsSuper() bool
func (*SessionInfo) NextKey ¶
func (s *SessionInfo) NextKey() crypto.Binary
NextKey rotates the key for a session. We do this to reduce the window during which a key is used.
type SessionPool ¶
type SessionPool struct { Pool map[int64]*SessionInfo // contains filtered or unexported fields }
SessionPool is the global pool of all sessions.
func (*SessionPool) Add ¶
func (s *SessionPool) Add(sess *SessionInfo) (id int64, err error)
Add adds a session to the pool
func (*SessionPool) Delete ¶
func (s *SessionPool) Delete(id int64)
Delete removes a session from the pool
func (*SessionPool) Get ¶
func (s *SessionPool) Get(id int64) (sess *SessionInfo)
Get retrieves a session from the pool
func (*SessionPool) Pruner ¶
func (s *SessionPool) Pruner()
Pruner is a continuous loop that removes expired sessions.