Passwordless authentication for your users using just an email address.
This repository contains the source code of the SimpleAuth.link API Service.
Read full documentation here.
- By leveraging the Ed25519 signature algorithm, the service deterministically generates a private key using your App ID and secret.
- This ensures that each token is cryptographically secure and uniquely tied to your application, eliminating the need to store sensitive keys.
- SimpleAuth.link works without a traditional database. It does not store any user data, including email addresses, on its servers.
- Instead, the data generated is self-contained, requiring no further information or state to be used. This stateless design increases security and reduces the risk of data breaches.
- Go (version 1.24 or later recommended)
- Docker (optional, for containerized deployment)
git clone --branch v2 https://github.com/SimpleAuthLink/authapi.git
cd authapi-
Modularity: The repository is structured into packages to simplify testing and future expansion.
api/: Contains the core API endpoint definitions and routing logic.cmd/: Entry points and command-line utilities for running the API server.docker/: Dockerfiles and configuration for containerized builds.internal/: Internal packages and libraries used across the application.notification/: Code handling user notifications.token/: Modules for token creation and management..github/: GitHub-specific workflows and configurations (CI/CD, issue templates, etc.).
This layout supports modular development and clear separation of concerns across different parts of the API service.
-
Testing: Use the standard Go testing framework to run tests. You can run tests with:
go test ./...
For development purposes, you can run the API server directly with Go.
go run ./cmd/authapi -hUsage of authapi:
-email-addr string
email account address
-email-host string
email server host
-email-pass string
email account password
-email-port int
email server port (default 587)
-host string
service host (default "0.0.0.0")
-port int
service host (default 8080)
-secret string
secret used to generate the tokens (default "simpleauthlink-secret")-
Prepare the Environment File
Copy the
example.envfile to.envand edit the file to fill in your parameters:HOST="localhost" PORT=8080 EMAIL_ADDR="[email protected]" EMAIL_PASS="smtp_server_password" EMAIL_HOST="smtp.example.com" EMAIL_PORT=587 SECRET="my_backend_secret"
-
Build the Docker Image
Run the following command in the root of your project to build the image:
docker build -f docker/Dockerfile.prod -t simpleauthlink . -
Run the Docker Container
Once the image is built, start a container using the environment file:
docker run --name simpleauthlink --env-file .env -p 8080:80 simpleauthlink
This command maps the container’s port 80 to port 8080 on your host.