Fix: replace all settings.algorithm references with hardcoded ALGORITHM
SEC-11 removed algorithm from Settings but missed 3 call sites: - auth.py line 68: jwt.decode in get_current_user - integrations.py lines 58, 120: jwt.decode in OAuth callbacks All now use ALGORITHM constant or inline 'HS256'.
This commit is contained in:
parent
4e8b321ef8
commit
5294745704
2 changed files with 3 additions and 3 deletions
|
|
@ -55,7 +55,7 @@ async def strava_callback(
|
||||||
from app.config import get_settings
|
from app.config import get_settings
|
||||||
_settings = get_settings()
|
_settings = get_settings()
|
||||||
try:
|
try:
|
||||||
payload = jose_jwt.decode(state, _settings.secret_key, algorithms=[_settings.algorithm])
|
payload = jose_jwt.decode(state, _settings.secret_key, algorithms=["HS256"])
|
||||||
user_id = uuid_mod.UUID(payload["sub"])
|
user_id = uuid_mod.UUID(payload["sub"])
|
||||||
except (JWTError, KeyError, ValueError):
|
except (JWTError, KeyError, ValueError):
|
||||||
raise HTTPException(status_code=400, detail="Invalid or expired OAuth state")
|
raise HTTPException(status_code=400, detail="Invalid or expired OAuth state")
|
||||||
|
|
@ -117,7 +117,7 @@ async def polar_callback(
|
||||||
from app.config import get_settings
|
from app.config import get_settings
|
||||||
_settings = get_settings()
|
_settings = get_settings()
|
||||||
try:
|
try:
|
||||||
payload = jose_jwt.decode(state, _settings.secret_key, algorithms=[_settings.algorithm])
|
payload = jose_jwt.decode(state, _settings.secret_key, algorithms=["HS256"])
|
||||||
user_id = uuid_mod.UUID(payload["sub"])
|
user_id = uuid_mod.UUID(payload["sub"])
|
||||||
except (JWTError, KeyError, ValueError):
|
except (JWTError, KeyError, ValueError):
|
||||||
raise HTTPException(status_code=400, detail="Invalid or expired OAuth state")
|
raise HTTPException(status_code=400, detail="Invalid or expired OAuth state")
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ async def get_current_user(
|
||||||
|
|
||||||
# Standard JWT validation
|
# Standard JWT validation
|
||||||
try:
|
try:
|
||||||
payload = jwt.decode(token, settings.secret_key, algorithms=[settings.algorithm])
|
payload = jwt.decode(token, settings.secret_key, algorithms=[ALGORITHM])
|
||||||
user_id: str = payload.get("sub")
|
user_id: str = payload.get("sub")
|
||||||
if user_id is None:
|
if user_id is None:
|
||||||
raise credentials_exception
|
raise credentials_exception
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue