auth

package
v0.14.5 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2018 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthHandler

type AuthHandler interface {
	// Init initialize the handler.
	Init(jsonconf string) error

	// AddRecord adds persistent record to database.
	// Calls store.Users.AddAuthRecord("user", "auth.Level", "scheme", "unique", "passhash", "expiration")
	// Returns: auth level, error
	AddRecord(rec *Rec, secret []byte) (Level, error)

	// UpdateRecord updates existing record with new credentials. Returns a numeric error code to indicate
	// if the error is due to a duplicate or some other error.
	// store.UpdateAuthRecord("scheme", "unique", "secret")
	UpdateRecord(rec *Rec, secret []byte) error

	// Authenticate: given a user-provided authentication secret (such as "login:password"
	// return user ID, time when the secret expires (zero, if never) or an error code.
	// store.Users.GetAuthRecord("scheme", "unique")
	// Returns: user ID, user auth level, login expiration time, error.
	Authenticate(secret []byte) (*Rec, error)

	// IsUnique verifies if the provided secret can be considered unique by the auth scheme
	// E.g. if login is unique.
	// store.GetAuthRecord(scheme, unique)
	IsUnique(secret []byte) (bool, error)

	// GenSecret generates a new secret, if appropriate.
	GenSecret(rec *Rec) ([]byte, time.Time, error)

	// DelRecords deletes all authentication records for the given user.
	DelRecords(uid types.Uid) error
}

AuthHandler is the interface which auth providers must implement.

type Feature added in v0.14.4

type Feature uint16
const (
	Validated Feature = 1 << iota
)

type Level added in v0.14.4

type Level int
const (
	// LevelNone is undefined/not authenticated
	LevelNone Level = iota * 10
	// LevelAnon is anonymous user/light authentication
	LevelAnon
	// LevelAuth is fully authenticated user
	LevelAuth
	// LevelRoot is a superuser (currently unused)
	LevelRoot
)

Authentication levels.

func ParseAuthLevel added in v0.14.4

func ParseAuthLevel(name string) Level

func (Level) String added in v0.14.4

func (a Level) String() string

String implements Stringer interface: gets human-readable name for a numeric authentication level.

type Rec added in v0.14.4

type Rec struct {
	Uid       types.Uid
	AuthLevel Level
	Lifetime  time.Duration
	Features  Feature
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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