Skip to content

Coming from Kong ​

If you run Kong, Tyk or another gateway mainly to put API keys and rate limits in front of an API, and then bolt on a portal and billing, MicroAuth replaces that stack with one dependency in your app and one dashboard.

What changes ​

A gateway sits in the request path. Every call goes through it, so it is one more service to deploy, scale, secure and keep in sync with your routes.

MicroAuth does not proxy traffic. The SDK runs inside your API, keeps a cached snapshot of keys and limits in memory, and decides each request locally. Usage is reported in the background. If MicroAuth is briefly unreachable, known keys keep working from the cached snapshot.

A typical gateway setupMicroAuth
Where checks runA proxy in front of your APIInside your API process
Extra hop per requestYesNo
ConfigurationServices, routes, plugins, declarative filesA dashboard, and a management API if you want one
Developer portalSeparate product or projectIncluded, white-label, on your domain
Metered billingSeparate systemIncluded: credits, plans, Stripe, ledger

Concept map ​

KongMicroAuth
Service and RouteYour own FastAPI routes. Add Security(auth) to the ones that need a key
ConsumerCustomer, which is always a team
key-auth credentialCustomer API key (map_...), created by the customer on your portal
rate-limiting pluginRPS on the pay as you go default, on a plan, or as a custom limit
Monthly limits in rate-limitingMonthly cap on pay as you go, or a custom monthly quota per customer
acl groups for tiersMonthly plans, public or private
Disabling a consumerSuspend on the customer's page
Redis policy for cluster-wide limitsredis_url in the SDK (Redis)
Admin API and decKThe management API with an automation key
Developer portalYour branded portal, included on every plan

Migrate in five steps ​

Launch the API ​

Follow the Quickstart up to the SDK secret key. Pick the pricing preset closest to what you charge today. You can change it at any time on the Pricing page.

Recreate your tiers ​

Turn each Kong tier into a pay as you go default or a monthly plan with the same rate limit. For a handful of special accounts, use custom limits instead of a plan.

Accept both kinds of key for a while ​

MicroAuth issues its own keys, so existing Kong keys cannot be imported. Run both during the move. Kong's key-auth reads the apikey header by default and MicroAuth reads X-API-Key, so they do not collide:

python
from fastapi import Header, HTTPException, Security
from microauth_fastapi import Customer, MicroAuth

auth = MicroAuth(app)

async def caller(
    customer: Customer | None = Security(auth.optional),
    apikey: str | None = Header(default=None),
) -> str:
    if customer is not None:
        return customer.id          # new key: limits and billing apply
    if apikey and is_legacy_key(apikey):
        return f"legacy:{apikey[:6]}"  # old key: your existing check
    raise HTTPException(401, "Missing API key")

auth.optional lets requests without a MicroAuth key through to your legacy check. A request that does send a MicroAuth key still gets every check.

Move your customers ​

Share your portal address, or invite people from Customers (Invite customer). Each customer signs up, gets a key in seconds and sees a ready-to-run request. To invite in bulk, call POST /v1/tenants/{tenantId}/customers/invite with an automation key.

Switch off the gateway ​

When legacy traffic drops to zero, replace caller with Security(auth) and remove the route from Kong. Your API now serves directly, with one less service in the path.

Questions people ask ​

Can a customer bypass the checks? Only by bypassing your own code. The SDK runs in your process, so it is as strong as your deployment. Limits like RPS are exact per process, and exact across processes once Redis is set. See How MicroAuth works.

What happens if MicroAuth is down? Known keys keep working from the cached snapshot, and usage is queued and delivered later. See the FastAPI SDK guide for the exact rules.

Do I need FastAPI? No. The SDK API is three HTTP endpoints. See Any other language.

MicroAuth is a product of Zyref, LLC.