mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-06 07:11:13 +02:00
mcp: don't run API keys through JWT validation
_resolve_token tried the JWT path before checking for the gns3_ prefix, so every API-key connection logged a spurious "JWT rejected" ERROR from get_token_data. Check the prefix first, and downgrade the JWT-rejected log to WARNING — a rejected token is a client problem, not a server one.
This commit is contained in:
2 files changed
+12
-10
No files matched your search
@@ -115,10 +115,10 @@ class AuthService:
|
||||
token_use: str = payload.claims.get("type", "access")
|
||||
token_data = TokenData(username=username, token_version=token_version, token_use=token_use)
|
||||
except BadSignatureError as e:
|
||||
log.error("JWT rejected: bad signature (header alg: '%s', error: %s)", _extract_alg(token), e)
|
||||
log.warning("JWT rejected: bad signature (header alg: '%s', error: %s)", _extract_alg(token), e)
|
||||
raise auth_error("Invalid token signature")
|
||||
except (JoseError, ValidationError, ValueError) as e:
|
||||
log.error("JWT rejected: %s: %s (header alg: '%s')", type(e).__name__, e, _extract_alg(token))
|
||||
log.warning("JWT rejected: %s: %s (header alg: '%s')", type(e).__name__, e, _extract_alg(token))
|
||||
raise auth_error(f"Invalid token ({type(e).__name__})")
|
||||
return token_data
|
||||
|
||||
|
||||
Reference in new issue
Block a user