Skip to content

Commit 2bfb77a

Browse files
committed
pylint
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
1 parent 73ae423 commit 2bfb77a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

mcpgateway/middleware/auth_middleware.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@
3636
logger = logging.getLogger(__name__)
3737
security_logger = get_security_logger()
3838

39+
# HTTPException detail strings that indicate security-critical rejections
40+
# (revoked tokens, disabled accounts, fail-secure validation errors).
41+
# Only these trigger a hard JSON deny in the auth middleware; all other
42+
# 401/403s fall through to route-level auth for backwards compatibility.
43+
_HARD_DENY_DETAILS = frozenset({"Token has been revoked", "Account disabled", "Token validation failed"})
44+
3945

4046
def _should_log_auth_success() -> bool:
4147
"""Check if successful authentication should be logged based on settings.
@@ -146,12 +152,6 @@ async def dispatch(self, request: Request, call_next: Callable) -> Response:
146152
logger.debug(f"Failed to close database session: {close_error}")
147153

148154
except HTTPException as e:
149-
# Only hard-deny for security-critical rejections (revoked tokens,
150-
# disabled accounts). Other 401s (e.g. malformed tokens, missing
151-
# claims) fall through so route-level auth can handle them — this
152-
# preserves backwards compatibility with registration scripts and
153-
# other callers that use minimal JWT claims.
154-
_HARD_DENY_DETAILS = frozenset({"Token has been revoked", "Account disabled", "Token validation failed"})
155155
if e.status_code in (401, 403) and e.detail in _HARD_DENY_DETAILS:
156156
logger.info(f"✗ Auth rejected ({e.status_code}): {e.detail}")
157157

0 commit comments

Comments
 (0)