{"id":19836533,"url":"https://github.com/wawandco/maildoor","last_synced_at":"2025-07-10T00:35:31.550Z","repository":{"id":37996313,"uuid":"453550706","full_name":"wawandco/maildoor","owner":"wawandco","description":"Email based authentication for Go","archived":false,"fork":false,"pushed_at":"2025-06-05T21:25:02.000Z","size":28530,"stargazers_count":17,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-05T21:30:38.384Z","etag":null,"topics":["authentication","awesome-go","email-based-login","embed","go","golang","passwordless","security","smtp","tailwindcss"],"latest_commit_sha":null,"homepage":"https://wawand.co","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wawandco.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-01-30T00:15:49.000Z","updated_at":"2025-06-05T21:25:04.000Z","dependencies_parsed_at":"2024-05-10T20:28:32.170Z","dependency_job_id":"225b1e43-4900-496a-8c54-1f9e1880ef56","html_url":"https://github.com/wawandco/maildoor","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/wawandco/maildoor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wawandco%2Fmaildoor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wawandco%2Fmaildoor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wawandco%2Fmaildoor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wawandco%2Fmaildoor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wawandco","download_url":"https://codeload.github.com/wawandco/maildoor/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wawandco%2Fmaildoor/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264506245,"owners_count":23619002,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authentication","awesome-go","email-based-login","embed","go","golang","passwordless","security","smtp","tailwindcss"],"created_at":"2024-11-12T12:11:37.174Z","updated_at":"2025-07-10T00:35:31.493Z","avatar_url":"https://github.com/wawandco.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![report card](https://goreportcard.com/badge/github.com/wawandco/maildoor)](https://goreportcard.com/report/github.com/wawandco/maildoor)\n\n# Maildoor\n\nMaildoor is an email based authentication library that allows users to sign up and sign in to your application using their email address. It is a pluggable library that can be used with any go http server.\n\n### Usage\n\nUsing maildoor is as simple as creating a new instance of the maildoor.Handler and passing it to your http server.\n\n```go\n// Initialize the maildoor handler\nauth := maildoor.New(\n\tmaildoor.Logo(\"https://example.com/logo.png\"),\n\tmaildoor.ProductName(\"My App\"))\n\tmaildoor.Prefix(\"/auth/\"), // Prefix for the routes\n\n\t// Defines the email sending mechanism which is up to the\n\t// host application to implement.\n\tmaildoor.EmailSender(func(to, html, txt string) error{\n\t\t// Send email to the user that's loggin in'\n\t\treturn smtp.Send(to, html, txt)\n\t}),\n\n\t// Defines the email validation mechanism\n\tmaildoor.EmailValidator(func(email string) bool {\n\t\t// Validate email with the users package\n\t\treturn users.UserExists(email)\n\t}),\n\n\t// Defines what to do after the user has successfuly logged in\n\t// This is where you would set the user session or redirect to a private page\n\tmaildoor.AfterLogin(func w http.ResponseWriter, r http.Request) {\n\t\t// Redirect to the private page\n\t\thttp.Redirect(w, r, \"/private\", http.StatusFound)\n\t}),\n\n\t// Defines what to do after the user has successfuly loged out\n\t// This is where you would clear the user session or redirect to a login page\n\tmaildoor.Logout(func(w http.ResponseWriter, r *http.Request){\n\t\thttp.Redirect(w, r, \"/auth/login\", http.StatusFound)\n\t}),\n})\n\nmux := http.NewServeMux()\nmux.Handle(\"/auth\", auth)\nmux.Handle(\"/private\", secure(privateHandler))\nhttp.ListenAndServe(\":8080\", mux)\n```\n\n## Features\n\n- Pluggable http.Handler that can be used with any go http server\n- Customizable email sending mechanism\n- Customizable email validation mechanism\n- Customizable logo\n- Customizable product name\n- Custom renderer functions for login and code entry pages\n\n### Custom Renderers\n\nMaildoor now supports custom renderer functions that allow you to completely customize the appearance of the login and code entry pages. You can provide your own HTML templates while still leveraging maildoor's authentication logic.\n\n```go\nauth := maildoor.New(\n\tmaildoor.ProductName(\"My App\"),\n\tmaildoor.Logo(\"https://example.com/logo.png\"),\n\n\t// Custom login page renderer\n\tmaildoor.LoginRenderer(func(data maildoor.Attempt) (string, error) {\n\t\t// Return your custom HTML for the login page\n\t\thtml := `\u003chtml\u003e...your custom login page...\u003c/html\u003e`\n\t\treturn html, nil\n\t}),\n\n\t// Custom code entry page renderer\n\tmaildoor.CodeRenderer(func(data maildoor.Attempt) (string, error) {\n\t\t// Return your custom HTML for the code entry page\n\t\thtml := `\u003chtml\u003e...your custom code page...\u003c/html\u003e`\n\t\treturn html, nil\n\t}),\n\n\t// Other options...\n)\n```\n\nThe `maildoor.Attempt` struct contains:\n- `Logo` - URL of the logo image\n- `Icon` - URL of the icon image\n- `ProductName` - Name of your product\n- `Email` - The email address (available in code renderer)\n- `Error` - Error message if any validation failed\n- `Code` - The verification code (context-dependent)\n\n### Token Storage\n\nMaildoor uses configurable token storage to manage authentication codes. By default, it uses in-memory storage, but you can provide custom implementations for Redis, databases, or other backends.\n\n```go\n// Use default in-memory storage (no expiration)\nauth := maildoor.New(\n\tmaildoor.ProductName(\"My App\"),\n\t// ... other options\n)\n\n// Use in-memory storage with expiration\ntokenStorage := maildoor.NewInMemoryTokenStorage(5 * time.Minute)\nauth := maildoor.New(\n\tmaildoor.WithTokenStorage(tokenStorage),\n\tmaildoor.ProductName(\"My App\"),\n\t// ... other options\n)\n\n// Use custom storage (implement TokenStorage interface)\ncustomStorage := \u0026MyRedisStorage{}\nauth := maildoor.New(\n\tmaildoor.WithTokenStorage(customStorage),\n\tmaildoor.ProductName(\"My App\"),\n\t// ... other options\n)\n```\n\n### Roadmap\n\n- Out of the box time bound token generation\n- Time based token expiration out the box\n- Prevend CSRF attacks with token\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwawandco%2Fmaildoor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwawandco%2Fmaildoor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwawandco%2Fmaildoor/lists"}