Skip to content

Commit

Permalink
fix(online_judge): 获取解密apikey失败的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
XYCode-Kerman committed Apr 15, 2024
1 parent 2623008 commit 882c497
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions online_judge/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@

def get_apikey_decoded(apikey: Optional[str] = Depends(apikey_schema)) -> Dict[Any, Any]:
if not apikey:
raise HTTPException(status_code=401, detail="请提供API Key")
raise HTTPException(
status_code=401, detail="请提供API Key")

try:
decoded = jwt.decode(apikey, algorithms=['HS256'])
decoded = jwt.decode(
apikey, key=os.environ['SECRET'], algorithms=['HS256'])
except jwt.DecodeError:
raise HTTPException(status_code=401, detail="API Key无效")
except jwt.ExpiredSignatureError:
Expand Down

0 comments on commit 882c497

Please sign in to comment.