2026-05-12 11:02:52 +05:30
2026-05-11 10:34:07 +05:30
2026-05-13 02:00:21 +05:30
2026-05-11 16:58:20 +05:30

toknd — The Minimal Token Broker

Dashboard Screenshot

Building integrations is fun until you have to manage the tokens. Suddenly, you're writing cron jobs to handle refresh cycles, dealing with expired sessions in the middle of background tasks, and copying OAuth secrets manually across multiple microservices.

If you are building AI agents that need to take actions in the real world, the absolute last thing you want is your LLM trying to debug an OAuth redirect flow.

toknd is a minimal, centralized authentication and auth token broker and middleware with native multi-tenancy. Built with Bun, Hono, and Redis, it acts as a secure "wallet" that sits between your applications and the external APIs they need to access.

You just need to authenticate once. toknd manages the lifecycle of the tokens forever, securely isolated by tenant.


Why does this exist?

There are massive enterprise identity brokers (like Auth0 or Dex), and then there are reverse proxies (like oauth2-proxy). toknd is built to bridge the gap while remaining minimal and open-source. It provides the lightweight, developer-friendly infrastructure of a proxy, but with the specific "Token Vault" and Multi-Tenancy capabilities required for modern AI and microservice architectures—without the bloat, vendor lock-in, or SaaS costs.

Use-Cases

  • Multi-Tenant SaaS Platforms: If you are building a platform where your users need to connect their own GitHub or Google accounts, toknd handles the isolation. Use a unique tenantId for each of your customers to keep their credentials safe and separate.
  • The Ultimate AI Agent Wallet: Equip your autonomous agents with a secure keychain. When your agent needs to hit a service backed by oauth, like GitHub or Notion API, it just asks toknd for a token. It gets a short-lived Bearer token instantly, keeping your permanent secrets completely isolated from dynamic AI environments.
  • Set It and Forget It: toknd handles automated background refreshes. Your data ingestion pipelines, RAG syncs, and headless integration workers will never stall out due to a 401 Unauthorized error again.
  • Microservice Centralization: Stop implementing OAuth in every new service. Centralize your credentials so your microservices only need one internal API key to request valid access tokens for any configured provider.
  • Secure Secret Isolation: OAuth client IDs, secrets, and long-lived refresh tokens stay locked inside toknd's Redis vault, drastically reducing your attack surface. All you need to do is secure the store.

Features

  • Native Multi-Tenancy: Isolate tokens for unlimited users/tenants using a single instance.
  • Drop-in Infrastructure: Deploys in seconds via Docker (or Podman) Compose or just a simple Bun script.
  • Centralized Provider Management: Native support for managing multiple OAuth2 providers (Google, GitHub, Trakt, etc.).
  • API Key Security: Isolated and secure access to the broker via master API keys. Each instance can use its own key for isolation.
  • Web Dashboard: Built-in clean ad modern UI for managing provider configurations and viewing live token statuses.
  • Blisteringly Fast: Powered by Bun and Redis for ultra-low latency token retrieval.

Tech Stack


Getting Started

toknd is designed to be too easy to set-up. You can deploy it as a containerized service or host it directly on bare metal.

1. Environment Setup

Clone the repository and set up your environment:

git clone https://git.ramvignesh.dev/toknd_auth.git
cd toknd
cp .env.example .env

Open .env, define your own strong API_KEY, and map the ports (optional)

2. Choose Deployment Method

The easiest way to get up and running. This spins up both toknd and a dedicated Redis instance.

  • Production:
    docker compose up -d --build
    (or)
    podman compose up -d --build
    

Option B: Bare Metal

If you already have Bun and Redis running in your environment.

  1. Install Dependencies:

    bun install
    
  2. Start the Server:

    • Production: bun run start
    • Development: bun run dev

    Note: Make sure your Redis server is running and accessible via the HOST and PORT in your .env.


Usage & API Reference

toknd provides a built-in Scalar API Reference so you can explore and test endpoints right from your browser.

Multi-Tenancy & The Golden Rule

All protected endpoints require your master API key and a Tenant ID for isolation:

  1. Authentication: Use your API key in the Authorization header.
  2. Isolation: Pass your unique tenant identifier in the X-Tenant-ID header.
Authorization: Bearer <your_master_api_key>
X-Tenant-ID: <unique_user_or_org_id>

Starting an OAuth Flow

To connect a new account for a specific tenant, redirect the user to: http://localhost:3000/v1/auth/{provider}/login?tenantId={your_tenant_id}

The Dashboard

REST API too complicated to use? No problem! You absolutely don't have to manage everything via curl. Access the web dashboard to configure providers, trigger manual refreshes, and monitor token health: http://localhost:3000/app

(Authenticate using your Master API Key).


Contributing

This is an open-source passion project built to solve a real headache in modern application architecture. Pull requests, issues, and feature requests (especially for new built-in OAuth providers!) are highly encouraged.

License

MIT

S
Description
No description provided
Readme 991 KiB
Languages
TypeScript 90.2%
JavaScript 9.3%
Dockerfile 0.5%