Skip to content
downlevelPublic

About

Self-hosted passwordless login confirmed via Telegram: forward auth for nginx/Traefik/Caddy, OpenID Connect provider, SSO sessions

Topics

Resources

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

TeleLogin

CI Release Image License

Passwordless login for your self-hosted apps, confirmed in Telegram.

Put TeleLogin in front of any web app behind nginx, Traefik or Caddy and your users sign in by tapping a button in Telegram: no passwords to manage, no authenticator app to install. It runs on your server with your own bot, and also works as a small OpenID Connect provider.

Think of it as a lightweight alternative to Authelia or Authentik for when your users already have Telegram.

How it works

  1. A user opens your app. The reverse proxy asks TeleLogin whether the browser has a session; if not, it redirects to the TeleLogin login page.
  2. The user types their username. The page shows a two-digit number.
  3. Your bot sends them a Telegram message with the request's IP and browser, and a row of numbers plus a Deny button.
  4. They tap the matching number. The browser gets a session cookie and lands back on the app, which receives the verified identity in X-TeleLogin-User headers.

One confirmation signs the browser in to every app you connect, for 30 days by default. Number matching means a login you did not start cannot be approved by a careless tap: picking the wrong number denies the request.

Features

  • Forward auth for nginx, Traefik and Caddy: protect an app with a few lines of proxy configuration and no code in the app. Tested in CI against the real proxies.
  • OpenID Connect provider: authorization code flow with PKCE, discovery and RS256 ID tokens, for apps that already support an OIDC login.
  • Shared browser SSO across apps on the same host or on sibling subdomains.
  • Per-app access control: allow specific users, or every registered user.
  • Closed registration: users join only through invitations you create.
  • Account management from Telegram: see recent logins and active sessions, revoke them, or delete the account.
  • Raw API and JavaScript client if you want to build your own login UI.
  • Small to run: two containers (API and bot), SQLite, images for amd64 and arm64.

Is it for me?

TeleLogin is a good fit if you run a few self-hosted apps for yourself, your family or a small team, everyone already uses Telegram, and you want something simpler than a full identity provider.

Know its limits before you choose it:

  • It depends on Telegram. If Telegram is down or blocked on your network, nobody can start a new login (existing sessions keep working until they expire). A user who loses their Telegram account has to be removed and invited again by the operator.
  • There is no fallback method: no password, TOTP or WebAuthn.
  • One instance, one worker. Data lives in SQLite and rate limits are kept in memory, so it does not scale horizontally.
  • No groups, LDAP or SAML. Access is a per-app list of users. OIDC supports confidential clients only, with no consent screen (register only apps you trust), and ID tokens carry a username but no email address.

If you need any of those, Authelia or Authentik are the better tools.

Quick start

You need Docker Compose v2, a domain served over HTTPS by a reverse proxy, and a Telegram account. Run these commands from the root of this checkout.

  1. Create a bot. Talk to @BotFather, create a new bot and save its token and username (without @). Dedicate the bot to TeleLogin: TeleLogin polls it for updates, so another program reading the same bot would steal them.

  2. Configure. Generate the two server secrets and create the environment file:

    docker run --rm ghcr.io/downlevel/telelogin:2.0.0 python -m src.admin gen-secrets
    cp deploy/.env.example deploy/.env

    In deploy/.env, fill in BOT_TOKEN, BOT_USERNAME, SECRET_KEY and INTERNAL_API_KEY, and set PUBLIC_URL to TeleLogin's external HTTPS address, for example https://auth.example.com or https://example.com/telelogin. Keep SSO_COOKIE_SECURE=true. Set REGISTRATION_MODE=closed if only invited users should be able to sign up. Leave SSO_COOKIE_DOMAIN empty unless apps on sibling subdomains must share the login, and then only if you trust every subdomain. See Configuration for every other setting.

  3. Start it.

    docker compose -f deploy/docker-compose.yml up -d

    The API listens on 127.0.0.1:8000 on the host (API_PORT changes the port). Proxy your PUBLIC_URL to it, stripping any path prefix and blocking the internal endpoints, as shown in the proxy examples. If your proxy runs in Docker, follow Docker proxy networking instead: it removes the published port and joins the proxy to TeleLogin's network.

  4. Invite yourself.

    docker compose -f deploy/docker-compose.yml exec --user 10001 api python -m src.admin user invite alice

    The command prints a single-use https://t.me/... link, valid for 30 minutes (it sends no message). Open it in Telegram and press Start. alice is your TeleLogin username, the one you type on the login page; it does not have to match your Telegram username. Once linked, user list shows your numeric telegram_id. If the link expired, run user remove alice and invite again.

  5. Register an app and allow yourself.

    docker compose -f deploy/docker-compose.yml exec --user 10001 api python -m src.admin app add myapp --name "My App"
    docker compose -f deploy/docker-compose.yml exec --user 10001 api python -m src.admin app allow myapp alice
  6. Protect the app. Copy the nginx, Traefik or Caddy snippet from the integration guide with app id myapp, reload the proxy and open the app: you are sent to the login page, and a moment later your phone buzzes. Keep the app reachable only through the proxy, so nobody can bypass the check or forge the identity headers.

The admin commands run as the application user (--user 10001) so that files in the data volume keep the right owner. For an app on another subdomain, or one that speaks OpenID Connect, read Which mode do I need?

Documentation

I want to... Read
Connect an app: forward auth, OpenID Connect, proxy examples Integration guide
Manage users and apps Operator CLI
Look up an environment variable Configuration
Build a custom login UI API reference and the JavaScript client
Understand the data model, threat model and privacy Architecture and security model
Upgrade from 1.x Upgrade steps: read them before starting 2.0.0
Hack on TeleLogin Contributing

Community

Questions and ideas are welcome in Discussions; bugs go in Issues. Please report vulnerabilities privately, as described in the security policy.

License

TeleLogin is distributed under the Apache License, Version 2.0. See LICENSE.

About

Self-hosted passwordless login confirmed via Telegram: forward auth for nginx/Traefik/Caddy, OpenID Connect provider, SSO sessions

Topics

Resources

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages