auth

package
Version: v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2017 License: GPL-3.0 Imports: 2 Imported by: 7

Documentation

Index

Constants

View Source
const (
	// No error
	NoErr = iota
	// No change
	InfoNotModified
	// DB or other internal failure
	ErrInternal
	// The secret cannot be parsed or otherwise wrong
	ErrMalformed
	// Authentication failed (wrong password)
	ErrFailed
	// Duplicate credential
	ErrDuplicate
	// The operation is unsupported
	ErrUnsupported
	// Secret has expired
	ErrExpired
	// Policy violation, e.g. password too weak.
	ErrPolicy
)
View Source
const (
	// Undefined/not authenticated
	LevelNone = iota * 10
	// Anonymous user/light authentication
	LevelAnon
	// Fully authenticated user
	LevelAuth
	// Superuser (currently unused)
	LevelRoot
)

Authentication levels

Variables

This section is empty.

Functions

func AuthLevelName

func AuthLevelName(authLvl int) string

Types

type AuthErr

type AuthErr struct {
	Code int
	Err  error
}

Structure for reporting an error condition

func NewErr

func NewErr(code int, err error) AuthErr

func (AuthErr) IsError

func (a AuthErr) IsError() bool

type AuthHandler

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

	// Add persistent record to database. Returns a numeric error code to indicate
	// if the error is due to a duplicate or some other error.
	// store.AddAuthRecord("scheme", "unique", "secret")
	// Returns: auth level, error
	AddRecord(uid types.Uid, secret []byte, lifetime time.Duration) (int, AuthErr)

	// Update 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(uid types.Uid, secret []byte, lifetime time.Duration) AuthErr

	// 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, token expiration time, AuthErr.
	Authenticate(secret []byte) (types.Uid, int, time.Time, AuthErr)

	// Verify 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, AuthErr)

	// Generate a new secret, if appropriate.
	GenSecret(uid types.Uid, authLvl int, lifetime time.Duration) ([]byte, time.Time, AuthErr)
}

Interface which auth providers must implement

Source Files

Jump to

Keyboard shortcuts

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