auth

package
v0.0.0-...-98f8d24 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2020 License: Apache-2.0 Imports: 5 Imported by: 2

Documentation

Overview

Package auth provides basic system-wide authentication for ftpd.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessType

type AccessType int

AccessType is an access level.

const (
	NoPermission AccessType = iota
	ReadOnly
	ReadWrite
)

Access levels

func (AccessType) HasAccess

func (a AccessType) HasAccess(required AccessType) bool

HasAccess decides whether receiver a has required access level.

type Anonymous

type Anonymous struct{}

Anonymous is an authenticator that allows read-only login with the name "anonymous".

func (Anonymous) Login

func (Anonymous) Login(username, password string) AccessType

Login implements Auth.Login, and does nothing than verifying the name being "anonymous".

type Auth

type Auth interface {
	// Login verifies the username/password pair, possibly does
	// some logging, and returns the AccessType the user has to the
	// virtual filesystem.
	//
	// A single USER command invokes this method with password empty.
	Login(username, password string) AccessType
}

Auth is for an authenticator to implement.

type File

type File struct {
	// contains filtered or unexported fields
}

File represents an authenticator from an text file.

The file has lines that are either empty, begin with #, or with the following format:

[Username]:[Password]:["r" or "rw"]

The first colon ends the username, and the last ends the password. A line ending in "r" represents a read-only account, while one ending in "rw" represents a read-write one.

Usernames are unique and later ones overwrite existing ones.

func NewFile

func NewFile(filename string) (a *File, err error)

NewFile creates a new file based authenticator.

func (*File) Login

func (a *File) Login(username, password string) AccessType

Login implements Auth.Login.

type SingleAccount

type SingleAccount struct {
	Username, Password string
}

SingleAccount is an authenticator with a single username/password pair, granting read-write access.

func (*SingleAccount) Login

func (s *SingleAccount) Login(username, password string) AccessType

Jump to

Keyboard shortcuts

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