Commit graph

3 commits

Author SHA1 Message Date
Thiemo Kreuz
2f66b3754f tests: Remove @param docs from test code that just repeat the signature
These are not only 100% identical to the actual code, but also:
* It's error-prone. Some are already wrong.
* These test…() functions are not meant to be called from
  anywhere. What is the target audience for this documentation?
* There is a @dataProvider. What such @param tags actually do is
  document the provider, but in an odd place. Just looking at
  the provider should give the same information.
* The MediaWiki CodeSniffer allows to skip @param when there is
  a @dataProvider, for the reasone listed.

Change-Id: I0f6f42f9a15776df944a0da48a50f9d5a2fb6349
2021-01-21 03:41:23 +00:00
David Barratt
c36b320454
Handle CORS preflight request and prevent anon users from unsafe methods
Creates an OPTIONS handler that handles any OPTIONS requests that are
not already handled by a handler. CORS has no mechanism to ensure the
user is authenticated, so the Router will reject cross-origin requests
from anon users.

This change allows authenticated users to make cross-origin
requests if they authenticate with OAuth or if
$wgRestAllowCrossOriginCookieAuth is enabled.

Bug: T232176
Bug: T262712
Change-Id: I128b4bdbec4f6bea35142153c951fd7b79617106
2020-09-21 19:29:40 -04:00
Tim Starling
558471f044 Conditional request support
* Added ConditionalHeaderUtil, a conditional request helper class meant
  for composition into Handler. I evaluated the composer package
  micheh/psr7-cache for this role but I decided that I prefer DIY
  code rather than some rather ugly glue.
* Check conditional request headers prior to entry into
  Handler::execute(). Contrary to what was previously documented, use
  the results of getLastModified() and getETag() to set headers in the
  response. This is convenient and can be overridden in the Handler if
  desired by overriding a one-line function.
* Instead of locking up header parsing inside ConditionalHeaderUtil as
  was done in micheh/psr7-cache, make a start on a new reusable header
  parsing framework, with recursive descent parsers for HTTP-date and
  IfNoneMatch.

Change-Id: I260809081cad7701df8620ab03834158670d4230
2019-10-14 12:01:25 +11:00