-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
52 lines (45 loc) · 2.17 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""
This application serves as an API endpoint for the Signals and Trends project that connects
the frontend platform with the backend database.
"""
from dotenv import load_dotenv
from fastapi import Depends, FastAPI
from src import routers
from src.authentication import authenticate_user
load_dotenv()
app = FastAPI(
debug=False,
title="Future Trends and Signals API",
version="3.0.0-beta",
summary="""The Future Trends and Signals (FTSS) API powers user experiences on UNDP Future
Trends and Signals System by providing functionality to to manage signals, trends and users.""",
description="""The FTSS API serves as a interface for the
[UNDP Future Trends and Signals System](https://signals.data.undp.org),
facilitating interaction between the front-end application and the underlying relational database.
This API enables users to submit, retrieve, and update data related to signals, trends, and user
profiles within the platform.
As a private API, it mandates authentication for all endpoints to ensure secure access.
Authentication is achieved by including the `access_token` in the request header, utilising JWT tokens
issued by [Microsoft Entra](https://learn.microsoft.com/en-us/entra/identity-platform/access-tokens).
This mechanism not only secures the API but also allows for the automatic recording of user information
derived from the API token. Approved signals and trends can be accesses using a predefined API key for
integration with other applications.
""".strip().replace(
" ", " "
),
contact={
"name": "UNDP Data Futures Platform",
"url": "https://data.undp.org",
"email": "[email protected]",
},
openapi_tags=[
{"name": "signals", "description": "CRUD operations on signals."},
{"name": "trends", "description": "CRUD operations on trends."},
{"name": "users", "description": "CRUD operations on users."},
{"name": "choices", "description": "List valid options for forms fields."},
],
docs_url="/",
redoc_url=None,
)
for router in routers.ALL:
app.include_router(router=router, dependencies=[Depends(authenticate_user)])