auth

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2015 License: GPL-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package auth handles the server-side authentication and session management.

Index

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

func (a *SessionInfo) CheckACL(db gorm.DB, objects ...shared.ACL) bool

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.

func (*SessionPool) Validate

func (s *SessionPool) Validate(r *http.Request) (ok bool, id int64, body []byte)

Validate checks that a message belongs to a session, and returns the session ID and request body. func (s *SessionPool) Validate(id int64, msgMac string, url string, message []byte) (ok bool) {

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL