authenticator

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2020 License: ISC Imports: 7 Imported by: 0

Documentation

Overview

Package authenticator provides server and site authentication services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authenticator

type Authenticator struct {
	Users map[string]User `json:"users,omitempty"`
	// contains filtered or unexported fields
}

Authenticator represents a quiki server or site authentication service.

func Open

func Open(path string) (*Authenticator, error)

Open reads a user data file and returns an Authenticator for it. If the path does not exist, a new data file is created.

func (*Authenticator) Login

func (auth *Authenticator) Login(username, password string) (User, error)

Login attempts a user login, returning the user on success.

func (*Authenticator) NewUser

func (auth *Authenticator) NewUser(user User, password string) error

NewUser registers a new user with the given information.

The Password field of the struct should be left empty and the plain-text password passed to the function.

type User

type User struct {
	Username    string `json:"u"`
	DisplayName string `json:"d"`
	Email       string `json:"e"`
	Password    []byte `json:"p"`
}

User represents a user.

func (*User) GobDecode

func (user *User) GobDecode(data []byte) error

GobDecode allows users to be decoded from a session.

func (*User) GobEncode

func (user *User) GobEncode() ([]byte, error)

GobEncode allows users to be encoded for storage in a session.

Jump to

Keyboard shortcuts

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