authentication

package
v1.0.19 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2023 License: MIT-0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreatePasswordHash added in v1.0.17

func CreatePasswordHash(password string) ([]byte, error)

Types

type Authentication

type Authentication interface {
	// RequiresAuthentication check is supports auth
	RequiresAuthentication() bool
	// Authenticate check is credentials valid
	Authenticate(authType AuthenticationType, username string, password string) bool
	// UsernamePresent check is username exists
	UsernamePresent(username string) bool
	// AddUser to auth storage
	AddUser(username string, httpPassHash string, smtpPassHash string) error
	// UpdateUser in auth storage
	UpdateUser(username string, httpPassHash string, smtpPassHash string) error
	// DeleteUser from auth storage
	DeleteUser(username string) error
	// ListUsers from auth storage
	ListUsers(searchQuery string, offset, limit int) ([]UserResource, int, error)
}

Authentication interface represents a backend flow to store or retrieve messages

type AuthenticationType

type AuthenticationType = string
const (
	HTTP AuthenticationType = "http"
	SMTP                    = "smtp"
)

type FileAuth

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

FileAuth represents the authentication handler using file

func CreateFileAuthentication

func CreateFileAuthentication(authFilePath string) *FileAuth

func (*FileAuth) AddUser

func (fileAuth *FileAuth) AddUser(username string, httpPassHash string, smtpPassHash string) error

func (*FileAuth) Authenticate

func (fileAuth *FileAuth) Authenticate(authType AuthenticationType, username string, password string) bool

func (*FileAuth) DeleteUser added in v1.0.17

func (fileAuth *FileAuth) DeleteUser(username string) error

func (*FileAuth) ListUsers added in v1.0.17

func (fileAuth *FileAuth) ListUsers(searchQuery string, offset, limit int) ([]UserResource, int, error)

func (*FileAuth) RequiresAuthentication

func (fileAuth *FileAuth) RequiresAuthentication() bool

func (*FileAuth) UpdateUser added in v1.0.17

func (fileAuth *FileAuth) UpdateUser(username string, httpPassHash string, smtpPassHash string) error

func (*FileAuth) UsernamePresent

func (fileAuth *FileAuth) UsernamePresent(username string) bool

type Mongo added in v1.0.16

type Mongo struct {
	Collection *mongo.Collection
}

func CreateMongoDbAuthentication added in v1.0.16

func CreateMongoDbAuthentication(collection *mongo.Collection) *Mongo

func (*Mongo) AddUser added in v1.0.16

func (mongoClient *Mongo) AddUser(username string, httpPassHash string, smtpPassHash string) error

func (*Mongo) Authenticate added in v1.0.16

func (mongoClient *Mongo) Authenticate(authType AuthenticationType, username string, password string) bool

func (*Mongo) DeleteUser added in v1.0.17

func (mongoClient *Mongo) DeleteUser(username string) error

func (*Mongo) ListUsers added in v1.0.17

func (mongoClient *Mongo) ListUsers(searchQuery string, offset, limit int) ([]UserResource, int, error)

func (*Mongo) RequiresAuthentication added in v1.0.16

func (mongoClient *Mongo) RequiresAuthentication() bool

func (*Mongo) UpdateUser added in v1.0.17

func (mongoClient *Mongo) UpdateUser(username string, httpPassHash string, smtpPassHash string) error

func (*Mongo) UsernamePresent added in v1.0.16

func (mongoClient *Mongo) UsernamePresent(username string) bool

type UserResource added in v1.0.17

type UserResource struct {
	Username string
}

type UserRow added in v1.0.16

type UserRow struct {
	Username string `bson:"username"`
	HttpPass string `bson:"http_password"`
	SmtpPass string `bson:"smtp_password"`
}

Jump to

Keyboard shortcuts

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