diff --git a/.config b/.config deleted file mode 100644 index 76e4d2c..0000000 --- a/.config +++ /dev/null @@ -1,48 +0,0 @@ -[Entrypoint] MySQL Docker Image 8.0.31-1.2.10-server -[Entrypoint] No password option specified for new database. -[Entrypoint] A random onetime password will be generated. -[Entrypoint] Initializing database -2022-11-01T07:22:53.617612Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead. -2022-11-01T07:22:53.617741Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.31) initializing of server in progress as process 36 -2022-11-01T07:22:53.628281Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. -2022-11-01T07:22:54.023307Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. -2022-11-01T07:22:55.089035Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option. -[Entrypoint] Database initialized -2022-11-01T07:22:58.383764Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead. -2022-11-01T07:22:58.385433Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.31) starting as process 85 -2022-11-01T07:22:58.409636Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. -2022-11-01T07:22:58.535223Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. -2022-11-01T07:22:58.778898Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed. -2022-11-01T07:22:58.778941Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel. -2022-11-01T07:22:58.802122Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: /var/run/mysqld/mysqlx.sock -2022-11-01T07:22:58.802172Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.31' socket: '/var/lib/mysql/mysql.sock' port: 0 MySQL Community Server - GPL. -Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it. -Warning: Unable to load '/usr/share/zoneinfo/leapseconds' as time zone. Skipping it. -Warning: Unable to load '/usr/share/zoneinfo/tzdata.zi' as time zone. Skipping it. -Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it. -Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it. -[Entrypoint] GENERATED ROOT PASSWORD: J_A5d97Coq6W7;g7JNa@?U,4uJ;T=J;5 - -[Entrypoint] ignoring /docker-entrypoint-initdb.d/* - -2022-11-01T07:23:01.468120Z 11 [System] [MY-013172] [Server] Received SHUTDOWN from user root. Shutting down mysqld (Version: 8.0.31). -2022-11-01T07:23:02.357833Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.31) MySQL Community Server - GPL. -[Entrypoint] Server shut down -[Entrypoint] Setting root user as expired. Password will need to be changed before database can be used. - -[Entrypoint] MySQL init process done. Ready for start up. - -[Entrypoint] Starting MySQL 8.0.31-1.2.10-server -2022-11-01T07:23:02.726006Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead. -2022-11-01T07:23:02.727404Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.31) starting as process 1 -2022-11-01T07:23:02.736685Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. -2022-11-01T07:23:02.863884Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. -2022-11-01T07:23:03.127363Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed. -2022-11-01T07:23:03.127421Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel. -2022-11-01T07:23:03.156352Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock -2022-11-01T07:23:03.156377Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.31' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server - GPL. -gitpod /workspace/fastapi_auth (main) $ - -sudo docker exec -it mysqlserver bash - -mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'linda321'; \ No newline at end of file diff --git a/README.md b/README.md index d0a5186..16e7911 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,13 @@ API key based Authentication package for FastAPI, focused on simplicity and ease - Username, Email address and password(hashing + salting) verification features. - Lightweight, minimal dependencies required. -This package can be used for development(sqlite3 database) and production(postgres database) environments. - +## Updates +1. Added **partial** support for mongodb database backend. +2. Added support for environment variables through .env files. +3. Added `example.env` file to show how to use environment variables. +4. Updated `README.md` to reflect changes. +5. Updated documentation to reflect changes. +6. Working on adding support for `mysql` database backend. ## Installation @@ -40,7 +45,7 @@ from fastapi_auth import api_key_router, api_key_security app = FastAPI( - description="FastAPI Auth is a package that provides authentication based API security with FastAPI and Postgres Database or Sqlite3 Database.", + description="FastAPI Auth is a package that provides authentication based API security with FastAPI and Postgres Database, SQLite Database or MongoDB Database", title="FastAPI Auth Example", version=1.0, ) @@ -82,6 +87,7 @@ And finally, you can use this API key to access the secure endpoint. ![secure endpoint](images/secure_endpoint.png) + ### API key creation in python You can of course automate API key acquisition through python with `requests` and directly querying the endpoints. diff --git a/api/app.py b/api/app.py index 5576676..12d7e6c 100644 --- a/api/app.py +++ b/api/app.py @@ -4,7 +4,7 @@ from fastapi_auth import api_key_router, api_key_security app = FastAPI( - description="FastAPI Auth is a package that provides authentication based API security with FastAPI and Postgres Database or Sqlite3 Database.", + description="FastAPI Auth is a package that provides authentication based API security with FastAPI and Postgres Database, Sqlite3 Database or MongoDB Database.", title="FastAPI Auth Example", version=1.0, ) diff --git a/data.json b/data.json deleted file mode 100644 index 711cb19..0000000 --- a/data.json +++ /dev/null @@ -1,180 +0,0 @@ -[ - {'_id': ObjectId('636291cf8bfed6c0907efc81'), 'api_key': 'd2f0e4f7-adb8-4a7e-a04b-73b5f0b8fcd7', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 50: 39', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$U6nY8MBZ6t5CSSqJJUfq5eDZ6ih7GM/LD3jvlVPMACIZknJCm.6X.' - } -] - [ - {'_id': ObjectId('636291cf8bfed6c0907efc81'), 'api_key': 'd2f0e4f7-adb8-4a7e-a04b-73b5f0b8fcd7', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 50: 39', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$U6nY8MBZ6t5CSSqJJUfq5eDZ6ih7GM/LD3jvlVPMACIZknJCm.6X.' - }, - {'_id': ObjectId('6362929c2223851f64c4f973'), 'api_key': 'ec1d2788-6baa-4bcc-9a13-73acdc55bce3', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 54: 04', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$Uoh9kH6skv8.2n8iIW2kQO713FHAu4I1bX0ADjrZl3Yrc7oRg9kA2' - } -] - [ - {'_id': ObjectId('636291cf8bfed6c0907efc81'), 'api_key': 'd2f0e4f7-adb8-4a7e-a04b-73b5f0b8fcd7', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 50: 39', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$U6nY8MBZ6t5CSSqJJUfq5eDZ6ih7GM/LD3jvlVPMACIZknJCm.6X.' - }, - {'_id': ObjectId('6362929c2223851f64c4f973'), 'api_key': 'ec1d2788-6baa-4bcc-9a13-73acdc55bce3', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 54: 04', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$Uoh9kH6skv8.2n8iIW2kQO713FHAu4I1bX0ADjrZl3Yrc7oRg9kA2' - }, - {'_id': ObjectId('636292ab2223851f64c4f975'), 'api_key': 'f00fdf85-b103-450f-9670-8feb085d2037', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 54: 19', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$Na7wWxY..oHLVnYuWuUhOuXpQSiZ2/H3GDujVCWHRYQ/NDEz7bU46' - } -] - [ - {'_id': ObjectId('636291cf8bfed6c0907efc81'), 'api_key': 'd2f0e4f7-adb8-4a7e-a04b-73b5f0b8fcd7', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 50: 39', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$U6nY8MBZ6t5CSSqJJUfq5eDZ6ih7GM/LD3jvlVPMACIZknJCm.6X.' - }, - {'_id': ObjectId('6362929c2223851f64c4f973'), 'api_key': 'ec1d2788-6baa-4bcc-9a13-73acdc55bce3', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 54: 04', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$Uoh9kH6skv8.2n8iIW2kQO713FHAu4I1bX0ADjrZl3Yrc7oRg9kA2' - }, - {'_id': ObjectId('636292ab2223851f64c4f975'), 'api_key': 'f00fdf85-b103-450f-9670-8feb085d2037', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 54: 19', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$Na7wWxY..oHLVnYuWuUhOuXpQSiZ2/H3GDujVCWHRYQ/NDEz7bU46' - }, - {'_id': ObjectId('636293010c9d48868de8fef3'), 'api_key': 'a16b4987-a25f-494c-8e0f-9c00799e0e8d', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 55: 45', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$3ykLA7k4.UqOvnxJTK1l6O4vtXp2yU9ZE0MTjQYrlMvs2Cu/./NXO' - } -] - [ - {'_id': ObjectId('636291cf8bfed6c0907efc81'), 'api_key': 'd2f0e4f7-adb8-4a7e-a04b-73b5f0b8fcd7', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 50: 39', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$U6nY8MBZ6t5CSSqJJUfq5eDZ6ih7GM/LD3jvlVPMACIZknJCm.6X.' - }, - {'_id': ObjectId('6362929c2223851f64c4f973'), 'api_key': 'ec1d2788-6baa-4bcc-9a13-73acdc55bce3', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 54: 04', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$Uoh9kH6skv8.2n8iIW2kQO713FHAu4I1bX0ADjrZl3Yrc7oRg9kA2' - }, - {'_id': ObjectId('636292ab2223851f64c4f975'), 'api_key': 'f00fdf85-b103-450f-9670-8feb085d2037', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 54: 19', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$Na7wWxY..oHLVnYuWuUhOuXpQSiZ2/H3GDujVCWHRYQ/NDEz7bU46' - }, - {'_id': ObjectId('636293010c9d48868de8fef3'), 'api_key': 'a16b4987-a25f-494c-8e0f-9c00799e0e8d', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 55: 45', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$3ykLA7k4.UqOvnxJTK1l6O4vtXp2yU9ZE0MTjQYrlMvs2Cu/./NXO' - }, - {'_id': ObjectId('636293b351df253217dbc80f'), 'api_key': '7f149817-c97f-445f-8d56-75ad88057e33', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 58: 43', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$DlB2AZ4OjOq9idvLf8ojMeLjMWy1LmT/xbI8xngOQr8DsNfWchlq6' - } -] - [ - {'_id': ObjectId('636291cf8bfed6c0907efc81'), 'api_key': 'd2f0e4f7-adb8-4a7e-a04b-73b5f0b8fcd7', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 50: 39', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$U6nY8MBZ6t5CSSqJJUfq5eDZ6ih7GM/LD3jvlVPMACIZknJCm.6X.' - }, - {'_id': ObjectId('6362929c2223851f64c4f973'), 'api_key': 'ec1d2788-6baa-4bcc-9a13-73acdc55bce3', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 54: 04', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$Uoh9kH6skv8.2n8iIW2kQO713FHAu4I1bX0ADjrZl3Yrc7oRg9kA2' - }, - {'_id': ObjectId('636292ab2223851f64c4f975'), 'api_key': 'f00fdf85-b103-450f-9670-8feb085d2037', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 54: 19', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$Na7wWxY..oHLVnYuWuUhOuXpQSiZ2/H3GDujVCWHRYQ/NDEz7bU46' - }, - {'_id': ObjectId('636293010c9d48868de8fef3'), 'api_key': 'a16b4987-a25f-494c-8e0f-9c00799e0e8d', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 55: 45', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$3ykLA7k4.UqOvnxJTK1l6O4vtXp2yU9ZE0MTjQYrlMvs2Cu/./NXO' - }, - {'_id': ObjectId('636293b351df253217dbc80f'), 'api_key': '7f149817-c97f-445f-8d56-75ad88057e33', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 58: 43', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$DlB2AZ4OjOq9idvLf8ojMeLjMWy1LmT/xbI8xngOQr8DsNfWchlq6' - }, - {'_id': ObjectId('636294bb25d1ab14f1f8a492'), 'api_key': '8befc6d2-8919-4530-8ebf-8fe0341b513a', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T16: 03: 07', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$zEhuJPIKM/KK3uP25VBY8eHAnEpODZzDOUGNb5T1OAm9dnIiSKmNO' - } -] - [ - {'_id': ObjectId('636291cf8bfed6c0907efc81'), 'api_key': 'd2f0e4f7-adb8-4a7e-a04b-73b5f0b8fcd7', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 50: 39', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$U6nY8MBZ6t5CSSqJJUfq5eDZ6ih7GM/LD3jvlVPMACIZknJCm.6X.' - }, - {'_id': ObjectId('6362929c2223851f64c4f973'), 'api_key': 'ec1d2788-6baa-4bcc-9a13-73acdc55bce3', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 54: 04', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$Uoh9kH6skv8.2n8iIW2kQO713FHAu4I1bX0ADjrZl3Yrc7oRg9kA2' - }, - {'_id': ObjectId('636292ab2223851f64c4f975'), 'api_key': 'f00fdf85-b103-450f-9670-8feb085d2037', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 54: 19', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$Na7wWxY..oHLVnYuWuUhOuXpQSiZ2/H3GDujVCWHRYQ/NDEz7bU46' - }, - {'_id': ObjectId('636293010c9d48868de8fef3'), 'api_key': 'a16b4987-a25f-494c-8e0f-9c00799e0e8d', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 55: 45', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$3ykLA7k4.UqOvnxJTK1l6O4vtXp2yU9ZE0MTjQYrlMvs2Cu/./NXO' - }, - {'_id': ObjectId('636293b351df253217dbc80f'), 'api_key': '7f149817-c97f-445f-8d56-75ad88057e33', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 58: 43', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$DlB2AZ4OjOq9idvLf8ojMeLjMWy1LmT/xbI8xngOQr8DsNfWchlq6' - }, - {'_id': ObjectId('636294bb25d1ab14f1f8a492'), 'api_key': '8befc6d2-8919-4530-8ebf-8fe0341b513a', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T16: 03: 07', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$zEhuJPIKM/KK3uP25VBY8eHAnEpODZzDOUGNb5T1OAm9dnIiSKmNO' - }, - {'_id': ObjectId('636295296dc724677eb41247'), 'api_key': '368d0d58-99ad-4c58-b198-a47ca7099cec', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T16: 04: 57', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$9PLo.s.t5sq8QmnIZBP1JuxOK3v/.nlVdOAEiyLgsgnIVq8Jusxkq' - } -] - [ - {'_id': ObjectId('636291cf8bfed6c0907efc81'), 'api_key': 'd2f0e4f7-adb8-4a7e-a04b-73b5f0b8fcd7', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 50: 39', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$U6nY8MBZ6t5CSSqJJUfq5eDZ6ih7GM/LD3jvlVPMACIZknJCm.6X.' - }, - {'_id': ObjectId('6362929c2223851f64c4f973'), 'api_key': 'ec1d2788-6baa-4bcc-9a13-73acdc55bce3', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 54: 04', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$Uoh9kH6skv8.2n8iIW2kQO713FHAu4I1bX0ADjrZl3Yrc7oRg9kA2' - }, - {'_id': ObjectId('636292ab2223851f64c4f975'), 'api_key': 'f00fdf85-b103-450f-9670-8feb085d2037', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 54: 19', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$Na7wWxY..oHLVnYuWuUhOuXpQSiZ2/H3GDujVCWHRYQ/NDEz7bU46' - }, - {'_id': ObjectId('636293010c9d48868de8fef3'), 'api_key': 'a16b4987-a25f-494c-8e0f-9c00799e0e8d', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 55: 45', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$3ykLA7k4.UqOvnxJTK1l6O4vtXp2yU9ZE0MTjQYrlMvs2Cu/./NXO' - }, - {'_id': ObjectId('636293b351df253217dbc80f'), 'api_key': '7f149817-c97f-445f-8d56-75ad88057e33', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 58: 43', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$DlB2AZ4OjOq9idvLf8ojMeLjMWy1LmT/xbI8xngOQr8DsNfWchlq6' - }, - {'_id': ObjectId('636294bb25d1ab14f1f8a492'), 'api_key': '8befc6d2-8919-4530-8ebf-8fe0341b513a', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T16: 03: 07', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$zEhuJPIKM/KK3uP25VBY8eHAnEpODZzDOUGNb5T1OAm9dnIiSKmNO' - }, - {'_id': ObjectId('636295296dc724677eb41247'), 'api_key': '368d0d58-99ad-4c58-b198-a47ca7099cec', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T16: 04: 57', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$9PLo.s.t5sq8QmnIZBP1JuxOK3v/.nlVdOAEiyLgsgnIVq8Jusxkq' - }, - {'_id': ObjectId('6362a5b2f08c972f6893c466'), 'api_key': '1a579e54-2d64-4db9-8770-2a705fe9a767', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T17: 15: 30', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi7', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$hAMiZ2YnKXmN3UfXc8EnXeIrIpyDibpM1p1hlv8/4022qV1vgj7IS' - } -] - [ - {'_id': ObjectId('636291cf8bfed6c0907efc81'), 'api_key': 'd2f0e4f7-adb8-4a7e-a04b-73b5f0b8fcd7', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 50: 39', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$U6nY8MBZ6t5CSSqJJUfq5eDZ6ih7GM/LD3jvlVPMACIZknJCm.6X.' - }, - {'_id': ObjectId('6362929c2223851f64c4f973'), 'api_key': 'ec1d2788-6baa-4bcc-9a13-73acdc55bce3', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 54: 04', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$Uoh9kH6skv8.2n8iIW2kQO713FHAu4I1bX0ADjrZl3Yrc7oRg9kA2' - }, - {'_id': ObjectId('636292ab2223851f64c4f975'), 'api_key': 'f00fdf85-b103-450f-9670-8feb085d2037', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 54: 19', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$Na7wWxY..oHLVnYuWuUhOuXpQSiZ2/H3GDujVCWHRYQ/NDEz7bU46' - }, - {'_id': ObjectId('636293010c9d48868de8fef3'), 'api_key': 'a16b4987-a25f-494c-8e0f-9c00799e0e8d', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 55: 45', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$3ykLA7k4.UqOvnxJTK1l6O4vtXp2yU9ZE0MTjQYrlMvs2Cu/./NXO' - }, - {'_id': ObjectId('636293b351df253217dbc80f'), 'api_key': '7f149817-c97f-445f-8d56-75ad88057e33', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 58: 43', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$DlB2AZ4OjOq9idvLf8ojMeLjMWy1LmT/xbI8xngOQr8DsNfWchlq6' - }, - {'_id': ObjectId('636294bb25d1ab14f1f8a492'), 'api_key': '8befc6d2-8919-4530-8ebf-8fe0341b513a', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T16: 03: 07', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$zEhuJPIKM/KK3uP25VBY8eHAnEpODZzDOUGNb5T1OAm9dnIiSKmNO' - }, - {'_id': ObjectId('636295296dc724677eb41247'), 'api_key': '368d0d58-99ad-4c58-b198-a47ca7099cec', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T16: 04: 57', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$9PLo.s.t5sq8QmnIZBP1JuxOK3v/.nlVdOAEiyLgsgnIVq8Jusxkq' - }, - {'_id': ObjectId('6362a5b2f08c972f6893c466'), 'api_key': '1a579e54-2d64-4db9-8770-2a705fe9a767', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T17: 15: 30', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi7', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$hAMiZ2YnKXmN3UfXc8EnXeIrIpyDibpM1p1hlv8/4022qV1vgj7IS' - }, - {'_id': ObjectId('6362a5d4f08c972f6893c468'), 'api_key': '7e1650ac-2deb-4b4c-9946-0f8bdfac6dd8', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T17: 16: 04', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi7', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$VVkBT7Oa6a245gWztUncj.yqDJiAmBScdlVmg0q6Llofur7ZPgZJi' - } -] - [ - {'_id': ObjectId('636291cf8bfed6c0907efc81'), 'api_key': 'd2f0e4f7-adb8-4a7e-a04b-73b5f0b8fcd7', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 50: 39', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$U6nY8MBZ6t5CSSqJJUfq5eDZ6ih7GM/LD3jvlVPMACIZknJCm.6X.' - }, - {'_id': ObjectId('6362929c2223851f64c4f973'), 'api_key': 'ec1d2788-6baa-4bcc-9a13-73acdc55bce3', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 54: 04', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$Uoh9kH6skv8.2n8iIW2kQO713FHAu4I1bX0ADjrZl3Yrc7oRg9kA2' - }, - {'_id': ObjectId('636292ab2223851f64c4f975'), 'api_key': 'f00fdf85-b103-450f-9670-8feb085d2037', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 54: 19', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$Na7wWxY..oHLVnYuWuUhOuXpQSiZ2/H3GDujVCWHRYQ/NDEz7bU46' - }, - {'_id': ObjectId('636293010c9d48868de8fef3'), 'api_key': 'a16b4987-a25f-494c-8e0f-9c00799e0e8d', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 55: 45', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$3ykLA7k4.UqOvnxJTK1l6O4vtXp2yU9ZE0MTjQYrlMvs2Cu/./NXO' - }, - {'_id': ObjectId('636293b351df253217dbc80f'), 'api_key': '7f149817-c97f-445f-8d56-75ad88057e33', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 58: 43', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$DlB2AZ4OjOq9idvLf8ojMeLjMWy1LmT/xbI8xngOQr8DsNfWchlq6' - }, - {'_id': ObjectId('636294bb25d1ab14f1f8a492'), 'api_key': '8befc6d2-8919-4530-8ebf-8fe0341b513a', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T16: 03: 07', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$zEhuJPIKM/KK3uP25VBY8eHAnEpODZzDOUGNb5T1OAm9dnIiSKmNO' - }, - {'_id': ObjectId('636295296dc724677eb41247'), 'api_key': '368d0d58-99ad-4c58-b198-a47ca7099cec', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T16: 04: 57', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$9PLo.s.t5sq8QmnIZBP1JuxOK3v/.nlVdOAEiyLgsgnIVq8Jusxkq' - }, - {'_id': ObjectId('6362a5b2f08c972f6893c466'), 'api_key': '1a579e54-2d64-4db9-8770-2a705fe9a767', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T17: 15: 30', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi7', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$hAMiZ2YnKXmN3UfXc8EnXeIrIpyDibpM1p1hlv8/4022qV1vgj7IS' - }, - {'_id': ObjectId('6362a5d4f08c972f6893c468'), 'api_key': '7e1650ac-2deb-4b4c-9946-0f8bdfac6dd8', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T17: 16: 04', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi7', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$VVkBT7Oa6a245gWztUncj.yqDJiAmBScdlVmg0q6Llofur7ZPgZJi' - }, - {'_id': ObjectId('6362a5dcf08c972f6893c46a'), 'api_key': '92063805-3d79-4055-a637-00f35e67815f', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T17: 16: 12', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi7', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$OCvg068AgHdx3Y4d8/sTAeXNmBXQAYe5LtjuJpSKqR9qY4GolWdoa' - } -] - [ - {'_id': ObjectId('636291cf8bfed6c0907efc81'), 'api_key': 'd2f0e4f7-adb8-4a7e-a04b-73b5f0b8fcd7', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 50: 39', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$U6nY8MBZ6t5CSSqJJUfq5eDZ6ih7GM/LD3jvlVPMACIZknJCm.6X.' - }, - {'_id': ObjectId('6362929c2223851f64c4f973'), 'api_key': 'ec1d2788-6baa-4bcc-9a13-73acdc55bce3', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 54: 04', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$Uoh9kH6skv8.2n8iIW2kQO713FHAu4I1bX0ADjrZl3Yrc7oRg9kA2' - }, - {'_id': ObjectId('636292ab2223851f64c4f975'), 'api_key': 'f00fdf85-b103-450f-9670-8feb085d2037', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 54: 19', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$Na7wWxY..oHLVnYuWuUhOuXpQSiZ2/H3GDujVCWHRYQ/NDEz7bU46' - }, - {'_id': ObjectId('636293010c9d48868de8fef3'), 'api_key': 'a16b4987-a25f-494c-8e0f-9c00799e0e8d', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 55: 45', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$3ykLA7k4.UqOvnxJTK1l6O4vtXp2yU9ZE0MTjQYrlMvs2Cu/./NXO' - }, - {'_id': ObjectId('636293b351df253217dbc80f'), 'api_key': '7f149817-c97f-445f-8d56-75ad88057e33', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 58: 43', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$DlB2AZ4OjOq9idvLf8ojMeLjMWy1LmT/xbI8xngOQr8DsNfWchlq6' - }, - {'_id': ObjectId('636294bb25d1ab14f1f8a492'), 'api_key': '8befc6d2-8919-4530-8ebf-8fe0341b513a', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T16: 03: 07', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$zEhuJPIKM/KK3uP25VBY8eHAnEpODZzDOUGNb5T1OAm9dnIiSKmNO' - }, - {'_id': ObjectId('636295296dc724677eb41247'), 'api_key': '368d0d58-99ad-4c58-b198-a47ca7099cec', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T16: 04: 57', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$9PLo.s.t5sq8QmnIZBP1JuxOK3v/.nlVdOAEiyLgsgnIVq8Jusxkq' - }, - {'_id': ObjectId('6362a5b2f08c972f6893c466'), 'api_key': '1a579e54-2d64-4db9-8770-2a705fe9a767', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T17: 15: 30', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi7', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$hAMiZ2YnKXmN3UfXc8EnXeIrIpyDibpM1p1hlv8/4022qV1vgj7IS' - }, - {'_id': ObjectId('6362a5d4f08c972f6893c468'), 'api_key': '7e1650ac-2deb-4b4c-9946-0f8bdfac6dd8', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T17: 16: 04', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi7', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$VVkBT7Oa6a245gWztUncj.yqDJiAmBScdlVmg0q6Llofur7ZPgZJi' - }, - {'_id': ObjectId('6362a5dcf08c972f6893c46a'), 'api_key': '92063805-3d79-4055-a637-00f35e67815f', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T17: 16: 12', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi7', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$OCvg068AgHdx3Y4d8/sTAeXNmBXQAYe5LtjuJpSKqR9qY4GolWdoa' - }, - {'_id': ObjectId('6362a6133bfc4c14d93180e9'), 'api_key': '49e29236-f6ce-4102-af4c-cedf3b728234', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T17: 17: 07', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi7', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$RokN8jk41UssYUCRkg8JgeDR8cQxF.Z9hAVAFtdWQrMLQnhSpNbRe' - } -] - [ - {'_id': ObjectId('636291cf8bfed6c0907efc81'), 'api_key': 'd2f0e4f7-adb8-4a7e-a04b-73b5f0b8fcd7', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 50: 39', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$U6nY8MBZ6t5CSSqJJUfq5eDZ6ih7GM/LD3jvlVPMACIZknJCm.6X.' - }, - {'_id': ObjectId('6362929c2223851f64c4f973'), 'api_key': 'ec1d2788-6baa-4bcc-9a13-73acdc55bce3', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 54: 04', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$Uoh9kH6skv8.2n8iIW2kQO713FHAu4I1bX0ADjrZl3Yrc7oRg9kA2' - }, - {'_id': ObjectId('636292ab2223851f64c4f975'), 'api_key': 'f00fdf85-b103-450f-9670-8feb085d2037', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 54: 19', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$Na7wWxY..oHLVnYuWuUhOuXpQSiZ2/H3GDujVCWHRYQ/NDEz7bU46' - }, - {'_id': ObjectId('636293010c9d48868de8fef3'), 'api_key': 'a16b4987-a25f-494c-8e0f-9c00799e0e8d', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 55: 45', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$3ykLA7k4.UqOvnxJTK1l6O4vtXp2yU9ZE0MTjQYrlMvs2Cu/./NXO' - }, - {'_id': ObjectId('636293b351df253217dbc80f'), 'api_key': '7f149817-c97f-445f-8d56-75ad88057e33', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T15: 58: 43', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$DlB2AZ4OjOq9idvLf8ojMeLjMWy1LmT/xbI8xngOQr8DsNfWchlq6' - }, - {'_id': ObjectId('636294bb25d1ab14f1f8a492'), 'api_key': '8befc6d2-8919-4530-8ebf-8fe0341b513a', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T16: 03: 07', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$zEhuJPIKM/KK3uP25VBY8eHAnEpODZzDOUGNb5T1OAm9dnIiSKmNO' - }, - {'_id': ObjectId('636295296dc724677eb41247'), 'api_key': '368d0d58-99ad-4c58-b198-a47ca7099cec', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T16: 04: 57', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$9PLo.s.t5sq8QmnIZBP1JuxOK3v/.nlVdOAEiyLgsgnIVq8Jusxkq' - }, - {'_id': ObjectId('6362a5b2f08c972f6893c466'), 'api_key': '1a579e54-2d64-4db9-8770-2a705fe9a767', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T17: 15: 30', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi7', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$hAMiZ2YnKXmN3UfXc8EnXeIrIpyDibpM1p1hlv8/4022qV1vgj7IS' - }, - {'_id': ObjectId('6362a5d4f08c972f6893c468'), 'api_key': '7e1650ac-2deb-4b4c-9946-0f8bdfac6dd8', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T17: 16: 04', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi7', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$VVkBT7Oa6a245gWztUncj.yqDJiAmBScdlVmg0q6Llofur7ZPgZJi' - }, - {'_id': ObjectId('6362a5dcf08c972f6893c46a'), 'api_key': '92063805-3d79-4055-a637-00f35e67815f', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T17: 16: 12', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi7', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$OCvg068AgHdx3Y4d8/sTAeXNmBXQAYe5LtjuJpSKqR9qY4GolWdoa' - }, - {'_id': ObjectId('6362a6133bfc4c14d93180e9'), 'api_key': '49e29236-f6ce-4102-af4c-cedf3b728234', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T17: 17: 07', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi7', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$RokN8jk41UssYUCRkg8JgeDR8cQxF.Z9hAVAFtdWQrMLQnhSpNbRe' - }, - {'_id': ObjectId('6362a894dfa1753ff7d1fddd'), 'api_key': 'a99397c3-b794-4de8-b4c3-6f4ce7298e4f', 'is_active': 1, 'never_expire': 0, 'expiration_date': '2022-11-17T17: 27: 48', 'latest_query_date': None, 'total_queries': 0, 'username': 'ifeanyi7', 'email': 'ifeanyinneji777@gmail.com', 'password': '$2b$12$cw29/QzPlm6W4rqG11l/WOgFg4E3afjbgAJrqCIKoYVX9bhnFufUG' - } -] \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index 6c9e79c..8f467b9 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,16 +1,18 @@ -# FastAPI Authentication +# fastapi_auth2 + + +[![Pypi](https://img.shields.io/pypi/v/fastapi_auth2.svg)](https://pypi.org/project/fastapi_auth2/) +[![PyPI - Python](https://img.shields.io/badge/python-3.6%20|%203.7%20|%203.8-blue.svg)](https://pypi.org/project/fastapi_auth2/) [![codecov](https://codecov.io/github/mrtolkien/fastapi_simple_security/branch/master/graph/badge.svg?token=8VIKJ9J3XF)](https://codecov.io/github/mrtolkien/fastapi_simple_security) [![Python Tests](https://github.com/mrtolkien/fastapi_simple_security/actions/workflows/pr_python_tests.yml/badge.svg)](https://github.com/mrtolkien/fastapi_simple_security/actions/workflows/pr_python_tests.yml) [![Linting](https://github.com/mrtolkien/fastapi_simple_security/actions/workflows/push_sanity_check.yml/badge.svg)](https://github.com/mrtolkien/fastapi_simple_security/actions/workflows/push_sanity_check.yml) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) -[![pre-commit enabled][pre-commit badge]][pre-commit project] - -[pre-commit badge]: -[pre-commit project]: - [![docs](https://github.com/Nneji123/fastapi_auth/actions/workflows/publish-docs.yml/badge.svg)](https://github.com/Nneji123/fastapi_auth/actions/workflows/publish-docs.yml) [![publish-pypi](https://github.com/Nneji123/fastapi_auth/actions/workflows/publish-pypi.yml/badge.svg)](https://github.com/Nneji123/fastapi_auth/actions/workflows/publish-pypi.yml) +[![Downloads](https://pepy.tech/badge/fastapi-auth2)](https://pepy.tech/project/fastapi-auth2) +[![Downloads](https://pepy.tech/badge/fastapi-auth2/month)](https://pepy.tech/project/fastapi-auth2) + API key based Authentication package for FastAPI, focused on simplicity and ease of use: @@ -21,8 +23,13 @@ API key based Authentication package for FastAPI, focused on simplicity and ease - Username, Email address and password(hashing + salting) verification features. - Lightweight, minimal dependencies required. -This package can be used for development(sqlite3 database) and production(postgres database) environments. - +## Updates +1. Added **partial** support for mongodb database backend. +2. Added support for environment variables through .env files. +3. Added `example.env` file to show how to use environment variables. +4. Updated `README.md` to reflect changes. +5. Updated documentation to reflect changes. +6. Working on adding support for `mysql` database backend. ## Installation @@ -38,7 +45,7 @@ from fastapi_auth import api_key_router, api_key_security app = FastAPI( - description="FastAPI Auth is a package that provides authentication based API security with FastAPI and Postgres Database or Sqlite3 Database.", + description="FastAPI Auth is a package that provides authentication based API security with FastAPI and Postgres Database, SQLite Database or MongoDB Database", title="FastAPI Auth Example", version=1.0, ) @@ -80,6 +87,7 @@ And finally, you can use this API key to access the secure endpoint. ![secure endpoint](images/secure_endpoint.png) + ### API key creation in python You can of course automate API key acquisition through python with `requests` and directly querying the endpoints. @@ -103,10 +111,7 @@ Environment variables: - When running the app inside Docker, use a bind mount for persistence - `FASTAPI_AUTH_AUTOMATIC_EXPIRATION`: Duration, in days, until an API key is deemed expired - 15 days by default -- `DEV_MODE`: If set to `True`, the app will run in development mode, using an in-memory sqlite database - - Useful for testing and development - - Not recommended for production - - If set to `False`, the app will run in production mode, using a postgres database. +- `DATABASE_MODE`: If set to `postgres`, the package will use a postgres database instead of sqlite - `URI`: Location of the postgres database - `postgresql://postgres:postgres@localhost:5432/postgres` by default - Only used if `DEV_MODE` is set to `False` @@ -140,7 +145,5 @@ The attached docker image runs a test app on `localhost:8080` with secret key `T docker-compose build && docker-compose up ``` -## TODO -- Add more tests -- Add more database backends -- Add more authentication methods +## License +[MIT](https://choosealicense.com/licenses/mit/) diff --git a/docs/sources/env_vars.md b/docs/sources/env_vars.md new file mode 100644 index 0000000..98eeeb6 --- /dev/null +++ b/docs/sources/env_vars.md @@ -0,0 +1,37 @@ +The fastapi_auth package uses exported environment variables or reads environment variables from a `.env` file. + +These are the environment variables that can be used: +# Database Settings +- DATABASE_MODE (default: sqlite) + +# MySQL settings +**For now mysql is not supported.** +- MYSQL_USER +- MYSQL_PASSWORD +- MYSQL_HOST +- MYSQL_PORT +- MYSQL_DATABASE +- MYSQL_URI + + + +# Postgres settings +** Set `DATABASE_MODE` to postgres to use postgres.** + +- POSTGRES_USER +- POSTGRES_PASSWORD +- POSTGRES_HOST +- POSTGRES_PORT +- POSTGRES_DATABASE +- POSTGRES_URI +- POSTGRES_SSL ("require" #delete if not used.) + +# MongoDB settings +** Set `DATABASE_MODE` to mongodb.** + +- MONGODB_URL + +# FastAPI_Auth settings +FASTAPI_AUTH_SECRET `set your secret key here` +FASTAPI_AUTH_AUTOMATIC_EXPIRATION=15 `Default=15` +FASTAPI_AUTH_DB_LOCATION=sqlite.db # `change location of sqlite.db` diff --git a/fastapi_auth/__init__.py b/fastapi_auth/__init__.py index 927ee72..8a65a3d 100644 --- a/fastapi_auth/__init__.py +++ b/fastapi_auth/__init__.py @@ -1,6 +1,6 @@ """Authentication Based API Security with FastAPI and Postgres Database or Sqlite3 Database. """ -__version__ = "1.0.4" +__version__ = "1.0.5" from fastapi_auth.endpoints import api_key_router from fastapi_auth.security_api_key import api_key_security diff --git a/fastapi_auth/_mongodb_access.py b/fastapi_auth/_mongodb_access.py index f08aff2..9d2ffca 100644 --- a/fastapi_auth/_mongodb_access.py +++ b/fastapi_auth/_mongodb_access.py @@ -53,6 +53,16 @@ def __init__(self): self.init_db() def init_db(self): + """ + The init_db function creates a new database in MongoDB. + + + Args: + self: Reference the class itself + + Returns: + A dictionary of the inserted document + """ try: connection = pymongo.MongoClient(MONGODB_URL) db = connection["test"] @@ -75,6 +85,20 @@ def init_db(self): print("Error while using mongodb:", e) def create_key(self, username, email, password, never_expire) -> dict: + """ + The create_key function creates a new api key for the user. It takes in username, email, password and never_expire as parameters. + It returns an api-key which is a string of random characters. + + Args: + self: Access variables that belongs to the class + username: Store the username of the user + email: Check if the user already exists in the database + password: Store the password of the user in a hashed format + never_expire: Determine if the api key will expire or not + + Returns: + A dictionary containing the api key + """ api_key = str(uuid.uuid4()) connection = pymongo.MongoClient(MONGODB_URL) db = connection["test"] @@ -107,6 +131,9 @@ def create_key(self, username, email, password, never_expire) -> dict: def renew_key(self, api_key: str, new_expiration_date: str) -> Optional[str]: + """ + This method has not been fully implemented yet. Will be worked on in future updates. + """ raise HTTPException(status = HTTP_422_UNPROCESSABLE_ENTITY, detail="This endpoint is tot implemented yet with Mongodb") @@ -151,6 +178,20 @@ def renew_key(self, api_key: str, new_expiration_date: str) -> Optional[str]: def revoke_key(self, api_key: str): + """ + The revoke_key function takes an API key as a parameter and sets the is_active field to false. + If the API key does not exist, it raises a 404 error. + + Args: + self: Access variables that belongs to the class + api_key:str: Specify the api_key that is to be revoked + + Returns: + this api key has been revoked + + Doc Author: + Trelent + """ connection = pymongo.MongoClient(MONGODB_URL) db = connection["test"] mycol = db["user"] @@ -164,9 +205,15 @@ def revoke_key(self, api_key: str): def check_key(self, api_key: str) -> Optional[str]: + """ + The check_key function has not been fully implemented yet. Will be worked on in future updates. + """ raise HTTPException(status = HTTP_422_UNPROCESSABLE_ENTITY, detail="This endpoint is tot implemented yet with Mongodb") def get_usage_stats(self) -> List[Tuple[str, bool, bool, str, str, int, str, str]]: + """ + The get_usage_stats function has not been fully implemented yet. Will be worked on in future updates. + """ raise HTTPException(status = HTTP_422_UNPROCESSABLE_ENTITY, detail="This endpoint is tot implemented yet with Mongodb") mongodb_access = MongodbAccess() diff --git a/mkdocs.yml b/mkdocs.yml index 1ec78af..3a5fe79 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -20,7 +20,9 @@ nav: - API: - Postgres Access: sources/api/fastapi_auth/Postgres_access.md - SQLite Access : sources/api/fastapi_auth/sqlite_access.md + - MongoDB Access: sources/api/fastapi_auth/mongodb_access.md - Security Access: sources/api/fastapi_auth/security_secret.md + - Environment Variables: sources/env_vars.md - Security Password: sources/security_password.md - Verification Checks: sources/verification_checks.md - Contributing: sources/contributing.md diff --git a/mkgendocs.yml b/mkgendocs.yml index b7b7ced..8633940 100644 --- a/mkgendocs.yml +++ b/mkgendocs.yml @@ -28,6 +28,17 @@ pages: - _update_usage - get_usage_stats + - page: "api/fastapi_auth/mongodb_access.md" + source: "fastapi_auth/_mongodb_access.py" + classes: + - MongodbAccess: + - init_db + - create_key + - renew_key + - revoke_key + - check_key + - get_usage_stats + - page: "api/fastapi_auth/security_secret.md" source: "fastapi_auth/_security_secret.py" classes: diff --git a/mongo.py b/mongo.py deleted file mode 100644 index 960a351..0000000 --- a/mongo.py +++ /dev/null @@ -1,61 +0,0 @@ -import os - -import pymongo -from dotenv import load_dotenv -# from fastapi_auth._mongodb_access import MONGODB_URL - -load_dotenv() - -# function names - -MONGODB_URL = os.getenv("MONGODB_URL") -connection = pymongo.MongoClient(MONGODB_URL) -db = connection["test"] -mycol = db["users"] -mydict = { - "api_key": "api_key", - "is_active": "is_active", - "never_expire": "never_expire", - "expiration_date": "expiration_date", - "latest_query_date": "latest_query_date", - "total_queries": "total_queries", - "username": "username", - "email": "email", - "password": "password", -} -# Create database -# mycol.insert_one(mydict) -# print("done") - -data = list() -for x in mycol.find(): - data.append(x) - print(data) - -email = "emal" -username= "username" - - -if email in mycol.find_one({'email': email}): - print("This username exists!") -else: - except Exception as e: - - print("done") - - -# value = data[0]["email"] -# print(value) - -# import pymongo - -# myclient = pymongo.MongoClient("mongodb://localhost:27017/") -# mydb = myclient["mydatabase"] -# mycol = mydb["customers"] - -# myquery = { "address": "Park Lane 38" } - -# if myquery in mycol.find(myquery): -# print("This data exists") -# else: -# print("this data does not exist") \ No newline at end of file