magiclinkauth

package module
v0.0.0-...-b6675cc Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2020 License: MIT Imports: 14 Imported by: 0

README

CodeCov Go Report Card codebeat badge GoDoc GitHub license Sourcegraph TODOs

magic-link-auth is a net/http Handler compatible library and middleware for performing secure password-less authentication but strictly 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://github.com/prologic/magic-link-auth.git
$ make
$ make test

Install

$ go get -u github.com/prologic/magic-link-auth

Example (TBD)

TBD

See the godoc for further documentation and other examples.

Stargazers over time

Stargazers over time

Support

Please support the ongoing development.

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. There is also Github's ownContributors statistics.

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