https://github.com/b4fun/tg-auth
https://github.com/b4fun/tg-auth
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/b4fun/tg-auth
- Owner: b4fun
- License: mit
- Created: 2022-12-15T05:05:07.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-12-23T22:34:04.000Z (over 2 years ago)
- Last Synced: 2025-03-05T14:03:20.301Z (2 months ago)
- Language: Go
- Size: 67.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
![]()
Authentication/authorization middleware with Telegram.**tg-auth** enables drop-in [Telegram based authn/z][telegram-login] to your service. No modifications needed for your application's code.
[telegram-login]: https://core.telegram.org/widgets/login

## Settings
tg-auth runs with following environment variables:
| Variable Name | Description | Sample |
|-----------:|:---|:---|
| `BOT_NAME` | Telegram bot name | |
| `BOT_TOKEN` | Telegram bot token | |
| `SIGNIN_URL` | URL endpoint of the signin protoal | `https://example.com/signin` |
| `SIGNIN_REDIRECT_CALLBACK_URL` | URL endpoint of the Telegram signin callback | `https://example.com/signin/callback` |
| `SIGNIN_AFTER_SIGNIN_URL` | URL endpoint after succeeded authentication | `https://example.com` |
| `AUTHZ_CHANNEL_IDS` | `,` separated Telegram channel id for checking user access permission | `-12345,-67890` |
| `AUTHZ_CACHE` | User access check cache TTL. Defaults to 5 minutes | `5m` |
| `AUTHN_COOKIE_SIGNING_KEY` | Base64 encoded AES signing key for encrypting cookie value. | |
| `AUTHN_COOKIE_NAME` | Name of the cookie | |
| `AUTHN_COOKIE_DOMAIN` | The domain of the cookie | `example.com` |
| `AUTHN_SESSION_TTL` | TTL of the cookie. Defaults to 1 hour | `1h` |## Examples
- Using with envoy: [examples/envoy](./examples/envoy/)
## LICENSE
MIT