This project demonstrates how to implement authentication in Telegram bot using OpenId Connect (OIDC).
Implementation tools:
- Keycloak — open source Identity and Access Management solution (OpenId provider).
- Spring Boot — application framework.
- TelegramBots — library to create Telegram Bots in Java.
- ScribeJava — OAuth client Java library.
- Java JWT от Auth0 — Java implementation of JSON Web Token (JWT).
This demo comprises of two services:
- Telegram bot
- OpenId provider
Ensure you have JDK 11. To build the project run:
./mvnw packageEnsure you have Docker and Docker Compose installed.
Create file .env in project root directory using .env.template as a base. Specify correct values for the
following entries:
BASEURL:http://address:8080whereaddressis an IP address/domain name of your host.OIDC_KEYCLOAK_BASEURL:http://address:8180whereaddressis an IP address/domain name of your host (do not uselocalhost).BOT_USERNAME: name of your telegram bot.BOT_TOKEN: token of your telegram bot.
Ok. Now, run the demo using following command:
docker-compose up --build