authenticationMongo

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: MIT-0 Imports: 11 Imported by: 2

README

MailHedgehog package to authenticate via MongoDB storage

All users data stored in MongoDB database. Useful if you have a lot of users in application.

Usage

package main

import (
    "github.com/mailhedgehog/gounit"
    "testing"
)

func Test(t *testing.T) {
    config := &contracts.AuthenticationConfig{}
    config.Smtp.ViaPasswordAuthentication.Enabled = true
    auth := CreateMongoDbAuthentication(createMongoTestCollection(), config)

    (*gounit.T)(t).AssertTrue(auth.SMTP().ViaPasswordAuthentication().Authenticate("user1", "secret"))
}

Development

go mod tidy
go mod verify
go mod vendor

Test

docker-compose up -d
go test --cover

Credits

  • Think Studio

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mongo

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

func CreateMongoDbAuthentication

func CreateMongoDbAuthentication(collection *mongo.Collection, config *contracts.AuthenticationConfig) *Mongo

func (*Mongo) Dashboard

func (mongo *Mongo) Dashboard() contracts.DashboardAuthentication

func (*Mongo) SMTP

func (mongo *Mongo) SMTP() contracts.SmtpAuthentication

func (*Mongo) UsersStorage

func (mongo *Mongo) UsersStorage() contracts.UsersStorage

type UserRow

type UserRow struct {
	Username            string   `bson:"username"`
	DashboardPass       string   `bson:"dashboard_password"`
	SmtpPass            string   `bson:"smtp_password"`
	SmtpAuthIPs         []string `bson:"smtp_auth_ips"`
	SmtpAllowListedIPs  []string `bson:"smtp_allow_listed_ips"`
	DashboardAuthEmails []string `bson:"dashboard_auth_emails"`
}

Jump to

Keyboard shortcuts

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