authapi

module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2025 License: AGPL-3.0

README ΒΆ

Last release GoDoc Go Report Card Build and Test license

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.


Technical Details πŸ’»

Token Generation Process πŸ”‘
  • 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.
Stateless Architecture πŸ•ŠοΈ
  • 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.

Development πŸ§‘β€πŸ’»

Prerequisites πŸ“
  • Go (version 1.24 or later recommended)
  • Docker (optional, for containerized deployment)
Clone the Repository πŸ“₯
git clone --branch v2 https://github.com/SimpleAuthLink/authapi.git
cd authapi
Code Structure πŸͺœ
  • 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 ./...
    
Run with go 🦫

For development purposes, you can run the API server directly with Go.

go run ./cmd/authapi -h
Usage 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")
Run with docker 🐳
  1. Prepare the Environment File

    Copy the example.env file to .env and edit the file to fill in your parameters:

    HOST="localhost"
    PORT=8080
    EMAIL_ADDR="test@test.com"
    EMAIL_PASS="smtp_server_password"
    EMAIL_HOST="smtp.example.com"
    EMAIL_PORT=587
    SECRET="my_backend_secret"
    
  2. 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 .
    
  3. 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.

Directories ΒΆ

Path Synopsis
api
io
cmd
authapi command
demo command
base64url
base64url package provides a way to encode and decode data using a modified base64 encoding scheme that is safe for URLs.
base64url package provides a way to encode and decode data using a modified base64 encoding scheme that is safe for URLs.

Jump to

Keyboard shortcuts

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