This article discusses the practical implementation of an authorization service based on the FastAPI framework using JWT tokens and asynchronous database interaction. The transition from using Keycloak to a lightweight specialized solution is justified under conditions of limited resources and the absence of a need for excessive functionality. The key architectural components are described: data models, the process of user registration and authentication, role-based access control, and route protection mechanisms. The proposed solution can be integrated into distributed information systems as a centralized authentication service.
microservice architecture, authorization, FastAPI, JWT, asynchronous programming, role-based access control, Python
1. Anshina, M. L. Arhitektura prilozheniy i dannyh : uchebnoe posobie / M. L. Anshina. – Moskva: RTU MIREA, 2024. – 152 s. – ISBN 978-5-7339-2218-8. – Tekst: elektronnyy // Lan': elektronno-bibliotechnaya sistema. – URL: https://e.lanbook.com/book/421100 (data obrascheniya: 16.10.2025).
2. Godzuras, E. Docker Compose dlya razrabotchika : rukovodstvo / E. Godzuras ; perevod s angliyskogo A. N. Kiseleva. – Moskva: DMK Press, 2023. – 220 s. – ISBN 978-5-93700-203-7. – Tekst: elektronnyy // Lan': elektronno-bibliotechnaya sistema. – URL: https://e.lanbook.com/book/348110 (data obrascheniya: 16.10.2025).
3. Kocher, P. S. Mikroservisy i konteynery Docker : rukovodstvo / P. S. Kocher ; perevod s angliyskogo A. N. Kiseleva. – Moskva: DMK Press, 2019. – 240 s. – ISBN 978-5-97060-739-8. – Tekst: elektronnyy // Lan': elektronno-bibliotechnaya sistema. – URL: https://e.lanbook.com/book/123710 (data obrascheniya: 16.10.2025).
4. Sumin, V. I. Ispol'zovanie situacionnogo modelirovaniya v razrabotke sistem prinyatiya resheniy dlya slozhnyh organizacionnyh sistem / V. I. Sumin, A. S. Kravchenko, A. V. Tolkachev // Modelirovanie sistem i processov. – 2024. – T. 17, № 3. – S. 71-79. – DOIhttps://doi.org/10.12737/2219-0767-2024-69-77.
5. FastAPI documentation. – URL: https://fastapi.tiangolo.com (data obrascheniya: 20.02.2026).
6. Passlib documentation. – URL: https://passlib.readthedocs.io (data obrascheniya: 20.02.2026).
7. SQLAlchemy 2.0 Documentation. – URL: https://docs.sqlalchemy.org (data obrascheniya: 20.02.2026).



