Skip to content

Commit

Permalink
Merge pull request #1455 from v-kamerdinerov/jose-to-jwt
Browse files Browse the repository at this point in the history
Migrate from python-jose to JWT and refactor dependencies
  • Loading branch information
ImMohammad20000 authored Nov 25, 2024
2 parents 497ca90 + a1001a9 commit 4f6d313
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 57 deletions.
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
**/node_modules
*.log
*.md
*.pyc
*.pyd
*.pyo
.docker*
.env*
.git*
.idea
.venv
.vscode
Dockerfile*
__pycache__
db.sqlite3
db.sqlite3-journal
docker-compose*.yml
v2ray-core
venv
xray-core
1 change: 0 additions & 1 deletion app/telegram/handlers/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from app.db import GetDB, crud
from app.models.user import UserResponse
from app.telegram import bot
from pytz import UTC
from telebot.custom_filters import ChatFilter
from telebot.util import extract_arguments

Expand Down
3 changes: 2 additions & 1 deletion app/templates/subscription/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ <h2>Links:</h2>
const qrCode = new QRCode(qrCodeContainer, {
text: link,
width: 256,
height: 256
height: 256,
correctLevel: QRCode.CorrectLevel.L
});
qrPopup.style.display = 'block';
});
Expand Down
6 changes: 3 additions & 3 deletions app/utils/jwt.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import time
import jwt
from base64 import b64decode, b64encode
from datetime import datetime, timedelta
from functools import lru_cache
from hashlib import sha256
from math import ceil
from typing import Union

from jose import JWTError, jwt

from config import JWT_ACCESS_TOKEN_EXPIRE_MINUTES

Expand Down Expand Up @@ -40,7 +40,7 @@ def get_admin_payload(token: str) -> Union[dict, None]:
created_at = None

return {"username": username, "is_sudo": access == "sudo", "created_at": created_at}
except JWTError:
except jwt.exceptions.PyJWTError:
return


Expand Down Expand Up @@ -86,5 +86,5 @@ def get_subscription_payload(token: str) -> Union[dict, None]:
return {"username": u_username, "created_at": datetime.utcfromtimestamp(u_created_at)}
else:
return
except JWTError:
except jwt.exceptions.PyJWTError:
return
70 changes: 18 additions & 52 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,78 +1,44 @@
alembic==1.8.1
anyio==3.6.2
APScheduler==3.9.1.post1
async-timeout==4.0.2
backports.zoneinfo==0.2.1;python_version<"3.9"
Deprecated==1.2.13
Jinja2==3.1.4
MarkupSafe==2.1.1
PyJWT==2.8.0
PyMySQL==1.1.1
PyYAML==6.0.2
SQLAlchemy==1.4.44
alembic==1.8.1
anyio==4.2.0
bcrypt==4.0.1
certifi==2024.07.04
cffi==1.17.1
charset-normalizer==2.1.1
click==8.1.3
click==8.1.7
commentjson==0.9.0
cryptography==43.0.1
Deprecated==1.2.13
ecdsa==0.19.0
fastapi==0.115.2
greenlet==3.1.1
grpcio==1.67.1
grpcio-tools==1.67.1
h11==0.14.0
grpcio==1.67.1
httptools==0.6.4
idna==3.7
importlib-metadata==5.1.0
importlib-resources==5.10.0
jdatetime==4.1.1
Jinja2==3.1.4
lark-parser==0.7.8
Mako==1.2.4
markdown-it-py==2.2.0
MarkupSafe==2.1.1
mdurl==0.1.2
packaging==21.3
passlib==1.7.4
Pillow==10.3.0
plumbum==1.8.1
protobuf==5.28.3
psutil==5.9.4
psycopg2-binary==2.9.7
pyasn1==0.4.8
pycparser==2.21
#pydantic==1.10.13
pydantic==1.10.16
Pygments==2.15.0
PyMySQL==1.1.1
pyOpenSSL==24.2.1
pyparsing==3.0.9
pypng==0.20220715.0
PySocks==1.7.1
pyTelegramBotAPI==4.9.0
pydantic==1.10.16
python-dateutil==2.8.2
python-decouple==3.6
python-dotenv==0.21.0
python-jose==3.3.0
python-dotenv==0.21.1
python-multipart==0.0.7
pytz==2022.6
pytz-deprecation-shim==0.1.0.post0
PyYAML==6.0.2
qrcode==7.4.2
redis==4.5.4
requests==2.32.0
rich==13.3.2
requests==2.32.3
rich==13.7.1
rpyc==6.0.0
rsa==4.9
six==1.16.0
sniffio==1.3.0
SQLAlchemy==1.4.44
starlette==0.40.0
typer==0.7.0
typing_extensions==4.8.0
tzdata==2022.6
tzlocal==4.2
typing_extensions==4.9.0
urllib3==1.26.19
uvicorn==0.19.0
uvloop==0.21.0
watchfiles==0.18.1
uvicorn==0.27.0.post1
websocket-client==1.7.0
websockets==10.4
wrapt==1.14.1
zipp==3.19.1
websockets==12.0

0 comments on commit 4f6d313

Please sign in to comment.