magiclinkauth

package module
v0.0.0-...-82d33cc Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2021 License: MIT Imports: 14 Imported by: 0

README

magic-link-auth is a net/http Handler compatible library and middleware for performing secure password-less authentication a form of OTP.

NOTE: By itself this should not be used as your primary authentication since it relies on the security of other 3rd-party components such as your email provider. It is strongly advised that you pair this with appropriate MFA.

Development

git clone https://git.mills.io/prologic/magic-link-auth.git
make
make test

Demo

go install go.mills.io/magic-link-auth/cmd/magic-link-auth-demo@latest
magic-link-auth-demo

Example (TBD)

TBD

See the Go Doec for further documentation and other examples.

Contributors

Thank you to all those that have contributed to this project, battle-tested it, used it in their own projects or products, fixed bugs, improved performance and even fix tiny typos in documentation! Thank you and keep contributing!

You can find an AUTHORS file where we keep a list of contributors to the project. If you contriibute a PR please consider adding your name there.

License

magic-link-auth is licensed under the term of the MIT License

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SMTP_SERVER = os.Getenv("SMTP_SERVER")
)

Functions

func CreateAuthToken

func CreateAuthToken(user string) (string, error)

func GenerateHashString

func GenerateHashString() (string, error)

func HasValidAuthToken

func HasValidAuthToken(v string) bool

func SendAuthEmail

func SendAuthEmail(recipient string, authHash, redirectURL string) error

Types

type AuthClaims

type AuthClaims struct {
	User string `json:"user"`
	jwt.StandardClaims
}

type MagicLinkAuth

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

func NewMagicLinkAuth

func NewMagicLinkAuth(db *bitcask.Bitcask) (*MagicLinkAuth, error)

func (*MagicLinkAuth) AuthHandler

func (m *MagicLinkAuth) AuthHandler(w http.ResponseWriter, r *http.Request)

func (*MagicLinkAuth) IsAuthenticated

func (m *MagicLinkAuth) IsAuthenticated(f http.HandlerFunc) http.HandlerFunc

func (*MagicLinkAuth) LoginHandler

func (m *MagicLinkAuth) LoginHandler(w http.ResponseWriter, r *http.Request)

func (*MagicLinkAuth) MagicLinkHandler

func (m *MagicLinkAuth) MagicLinkHandler(w http.ResponseWriter, r *http.Request)

func (*MagicLinkAuth) ProtectedHandler

func (m *MagicLinkAuth) ProtectedHandler(w http.ResponseWriter, r *http.Request)

func (*MagicLinkAuth) SaveMagicString

func (m *MagicLinkAuth) SaveMagicString(email string, hash string) error

func (*MagicLinkAuth) UnauthenticatedHandler

func (m *MagicLinkAuth) UnauthenticatedHandler(w http.ResponseWriter, r *http.Request)

type Sender

type Sender struct {
	User     string
	Password string
}

func NewSender

func NewSender(Username, Password string) Sender

func (Sender) SendMail

func (sender Sender) SendMail(recipients []string, subject string, body string) error

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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