authentication

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2023 License: MIT-0 Imports: 13 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
	// AuthenticateSMTPViaIP check is IP cab bypass password auth
	AuthenticateSMTPViaIP(username string, ip string) bool
	// SmtpIpIsWhitelisted check is IP allow to receive mails
	SmtpIpIsWhitelisted(username string, ip 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)
	// AddNoPassSmtpIp to auth storage related to user
	AddNoPassSmtpIp(username string, ip string) error
	// DeleteNoPassSmtpIp from auth storage related to user
	DeleteNoPassSmtpIp(username string, ip string) error
	// ClearAllNoPassSmtpIps in auth storage related to user
	ClearAllNoPassSmtpIps(username string) 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) AddNoPassSmtpIp added in v1.2.1

func (fileAuth *FileAuth) AddNoPassSmtpIp(username string, ip string) error

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) AuthenticateSMTPViaIP added in v1.2.1

func (fileAuth *FileAuth) AuthenticateSMTPViaIP(username string, ip string) bool

func (*FileAuth) ClearAllNoPassSmtpIps added in v1.2.1

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

func (*FileAuth) DeleteNoPassSmtpIp added in v1.2.1

func (fileAuth *FileAuth) DeleteNoPassSmtpIp(username string, ip string) error

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) SmtpIpIsWhitelisted added in v1.2.1

func (fileAuth *FileAuth) SmtpIpIsWhitelisted(username string, ip string) 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) AddNoPassSmtpIp added in v1.2.1

func (mongoClient *Mongo) AddNoPassSmtpIp(username string, ip string) error

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) AuthenticateSMTPViaIP added in v1.2.1

func (mongoClient *Mongo) AuthenticateSMTPViaIP(username string, ip string) bool

func (*Mongo) ClearAllNoPassSmtpIps added in v1.2.1

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

func (*Mongo) DeleteNoPassSmtpIp added in v1.2.1

func (mongoClient *Mongo) DeleteNoPassSmtpIp(username string, ip string) error

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) SmtpIpIsWhitelisted added in v1.2.1

func (mongoClient *Mongo) SmtpIpIsWhitelisted(username string, ip string) 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
	NoPassIPs     []string
	RestrictedIPs []string
	LoginEmails   []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"`
	NoPassIPs     []string `bson:"no_pass_ips"`
	RestrictedIPs []string `bson:"restricted_ips"`
	LoginEmails   []string `bson:"login_emails"`
}

Jump to

Keyboard shortcuts

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