There should be a way to exempt some routes from checks so that requests to them always pass through the gateway, even when the sender is otherwise rate-limited, and even when the request has an invalid JWT. We have three use cases for this:
- The /oauth2/access_token endpoint, which is used to request a new access token (using a refresh token or client credentials) when the old one expires. We want to ignore invalid JWTs, because signing this request with the expired access token is an easy mistake to make (right now this probably wouldn't work at the MediaWiki level either, but we should fix that); and we want to ignore rate limits, because since the access token expired, the user will be seen as unauthenticated when doing this request. If their lower, IP-based unauthenticated rates are already used up (they are on a cgNAT or run another, anonymous client from the same IP or whatever), they won't be able to reauthenticate.
- Maybe we should do the same for the /oauth2/authorize endpoint which is used to get an access token interactively (by sending the user to the authorization dialog). Less likely to be an actual problem, but there isn't really any disadvantage to doing it.
- The login-related action API endpoints (action=login, action=clientlogin, action=query&meta=tokens, maybe action=query&meta=authmanagerinfo), to allow users to become authenticated even when they are using a busy IP or their user-agent is being abused.
- The event intake endpoint (https://intake-logging.wikimedia.org/v1/events), if that goes through the API gateway at all. We probably don't want to break event logging just because the user has hit their API quota; we especially don't want to break JS error logging, since we want to use that to log rate limit errors. (JWT errors on this endpoint aren't possible as far as I can see, so this is about rate limiting only.)
The gateway only needs to deter abusive use of our infrastracture, not protect against DDoS (that happens at the edge), and neither of these endpoints can be abused, or are interesting to scrapers at all, and neither of them is particularly sensitive to high load, so exempting them should be fine AFAICS.