Commit graph

25 commits

Author SHA1 Message Date
Kunal Mehta
0944b7d39c AuthManager: Avoid deprecated wfMemcKey()
Change-Id: I254f9c057b8a151c593054dd4f2137586abf262a
2017-05-23 15:01:34 -07:00
addshore
b12086b618 Get ConfigFactory & MainConfig from MediaWikiServices
Change-Id: Iafdd7e00747060572463ffb05aae4543f3a06163
2016-11-23 00:12:38 +00:00
Kunal Mehta
61adc1e146 Use namespaced ScopedCallback
The un-namespaced \ScopedCallback is deprecated.

Change-Id: Ie014d5a775ead66335a24acac9d339915884d1a4
2016-10-17 15:46:05 -07:00
Aaron Schulz
9a8c8ab98c Make TransactionProfiler::setSilenced() calls handle nesting
Change-Id: I6511a72a0fb921468a8a19ceb4d0a8ae669aa6e4
2016-10-12 18:14:03 -07:00
Gergő Tisza
cdcc2a0e3f Avoid 'message' in log context in AuthManager
Logstash merges the log context into the main metadata (where
'message' is the log message) and ends up overwriting the message.

Bug: T145133
Change-Id: I27f221b0f1f7203e93d1b92119dc584ba8526f5b
2016-10-04 00:24:42 +00:00
Gergő Tisza
4a92749554 Fix some PhpStorm warnings in AuthManager
Change-Id: Ib5fab7a54a6572897d9b679d6470d830cbb3cea9
2016-09-12 22:55:51 +00:00
Gergő Tisza
55572b08a6 Avoid user autocreation race condition caused by repeatable read
AuthManager tries to check whether the user already exists if
User::addToDatabase fails in autocreation, but since the same DB row
was already checked a few lines earlier and this method is typically
wrapped in an implicit transaction, it will just re-read the same
snapshot and not do anything useful. addToDatabase already has
a check for that so let's rely on that instead.

Bug: T145131
Change-Id: I94a5e8b851dcf994f5f9e773edf4e9153a4a3535
2016-09-08 17:14:15 -07:00
Aaron Schulz
16266edff3 Change "slave" => "replica DB" in /includes
Change-Id: Icb716219c9335ff8fa447b1733d04b71d9712bf9
2016-09-05 21:01:01 +00:00
Gergő Tisza
94e2aa7b55 Expand SessionManager / AuthManager documentation
Bug: T110628
Bug: T142154
Change-Id: Ib0a41f01b3d12267b2a94ea1375e6d13cacd2b69
2016-08-30 18:54:30 +00:00
jenkins-bot
c039c6c6b9 Merge "Revert "AuthManager: Commit transaction after auto-creating a user"" 2016-08-18 20:16:47 +00:00
Aaron Schulz
5d20db748c Revert "AuthManager: Commit transaction after auto-creating a user"
* 81be9512a022 should obviate the main desire for this.
  The normal commit step is now relied upon again.
* 820f5d6ce5 and a26fbb6705 enforce DBO_TRX transactions.
* Committing the implicit transaction(s) prematurely is bad
  for web request and cross-DB transactionality. Only code
  that has clear outermost DB context (e.g. jobs/maintenance)
  should be doing things like this as it becomes hard to reason
  about (e.g. how much the request/caller needs atomicity
  or whether there is an outer (start|end)Atomic section).

This reverts commit 83c66caa08.

Change-Id: I1a5533b239e53f2089f239651c6fdf97e51c9062
2016-08-18 19:36:25 +00:00
Gergő Tisza
d4de10750f AuthManager: do not rewrite PRIMARY_REQUIRED to REQUIRED
AuthManager::getAuthenticationRequests() changes
AuthenticationRequest::$required from REQUIRED to PRIMARY_REQUIRED
if the request is from a primary; it made an exception when
all primary providers returned a given request. That exception is
not particularly useful (AuthenticationRequest::mergeFieldInfo()
used to rely on it to determine which fields are required, but
since I9d33bd2 that's not really needed), and knowing which request
is from a primary is useful for other means.

This changes required field semantics in a corner case: when a
primary provider returns two required requests, the previous
behavior was to assume that they are both required; the new one
is to treat them as alternatives (as if they were returned by
two different providers). So when all primary providers return
request X, and one of them returns Y in addition, the fields of X
will not be marked required, while previously that would have been
the case.

Instead of overcomplicating the interface for something that is
unlikely to come up in any real use case, add a new requirement
to PrimaryAuthenticationProvider that it should not return
multiple required requests.

Bug: T141471
Change-Id: I1c1f44d4d6b66f77c876e3459fb97f03483db744
2016-08-17 05:51:53 +00:00
Aaron Schulz
0d8c851d79 Make autoCreateUser() transaction profiler suppression limited in scope
Change-Id: If7b2330aa8cdf49ae25e5c0af5cb3ffc3f40b257
2016-08-15 14:10:33 -07:00
Gergő Tisza
854a462dc0 Remove $wgDisableAuthManager
Change-Id: I2b2c9693a275fcc026916bd97f303e7a5c8df341
2016-08-09 23:00:27 +00:00
Brad Jorsch
83c66caa08 AuthManager: Commit transaction after auto-creating a user
As things stand now, DBO_TRX or DBO_DEFAULT will cause a transaction to
be started, and then anything in the entire request failing will
probably cause the newly-added user row to be lost. But updates to
external databases (e.g. CentralAuth) likely won't be since those DB
connections were probably shut down after the update was completed.

So let's explicitly commit changes af the end of auto-creation so that
problems with the request itself don't undo it.

Bug: T119736
Change-Id: I6c13c8feb86d8b9a01df894733c38445d048fea0
2016-07-12 13:35:10 -04:00
Brad Jorsch
cd763560c8 Add $options parameter for testUserForCreation()
This will allow providers to know whether the call is just for testing
(from ApiQueryUsers) or for actual creation, and skip duplicate work
when testForAccountCreation() is going to be called.

Change-Id: Id3ef713fd377135d78f66e5100dedd4689293b59
Depends-On: I4af8b3b692f60c42f8685b90be5936da7ba4e2e2
Depends-On: Ie9639a15d04b387be0e72754301eb6d91cd8adc2
Depends-On: I063cbdfbd9a223bf2391fce2b714ab82ddd3272f
Depends-On: I7c67512634f6e72251911238f083857da9fd3f84
2016-06-20 11:27:07 -04:00
Brad Jorsch
50fa154511 Don't try to use the context language when auto-creating
Most of the time the context language won't be ready yet, because it
needs the user we're auto-creating.

Bug: T124367
Change-Id: I0376647be33e81593101378217b37363125cfddf
2016-06-13 12:52:41 -04:00
Brad Jorsch
e2522e7e7e Don't override action in UI and REDIRECT responses
In Ic8caf57eb, we changed things so the requests returned in a UI or
REDIRECT response would have the action forced to that appropriate for
the action being peformed. But ResetPasswordSecondaryAuthenticationProvider
has a use case where a mismatch is necessary: it's run during the login
action, but it needs a PasswordAuthenticationResponse for a change
action.

Bug: T136894
Change-Id: I9d109a22c5b2d2064f664f584100ecaab43199c5
2016-06-03 11:37:29 -04:00
Brad Jorsch
50b6fb32fb AuthManager::setDefaultUserOptions and LoginForm::initUser shouldn't invalidate CA tokens
We only want to set the local user_token when we create the local
account. We don't want to invalidate all existing CentralAuth sessions
for the user just because they happened to visit a new wiki and get
an account auto-created.

This might also fix T136853. It looks like what's going on there is that
two jobs are both in this code path calling CentralAuth::resetAuthToken()
at the same time, leading to a race and one fails the CAS check.

Bug: T136834
Change-Id: I61b8253584a11a5b02f7ccb9efa0679cd2a822c6
2016-06-02 19:35:27 +00:00
jenkins-bot
218e89d5b4 Merge "AuthManager: Ensure neededRequests have action and username set properly" 2016-06-01 21:26:13 +00:00
Brad Jorsch
3e970169f6 Make AuthManager::getAuthenticationProvider() public
I found a need in CentralAuth to check that
CentralAuthPrimaryAuthenticationProvider is actually in use, so I'm
exposing this.

Change-Id: I40bd3dc4d05db0c3a34b01f550a9a9a1ded8fc61
2016-06-01 14:16:49 -04:00
Brad Jorsch
db521e5574 AuthManager: Ensure neededRequests have action and username set properly
They were coming out as null instead, which screws up when requests are
changing their fields based on the action.

Change-Id: Ic8caf57ebad35c3eb17d45f9d96c6de5b559a83a
2016-06-01 12:13:15 -04:00
Chad Horohoe
ca831d5f45 Reset all tokens on login
Bug: T122056
Change-Id: I03739e942b6c182ed9cbcd0d9615dcd799e8baed
2016-05-31 12:20:05 -07:00
Brad Jorsch
9bb2875e2e AuthManager fixups around the login→RESTART→create flow
* ApiQueryAuthManagerInfo will differentiate between preserved linking
  data and a preserved createRequest.
* ApiQueryAuthManagerInfo will indicate the preserved username, if any,
  because the client will have to pass that back to action=createaccount.
* ApiClientLogin won't tell about the confusing
  CreateFromLoginAuthenticationRequest returned on RESTART responses.
* Explain how 'preservestate' works in ApiAMCreateAccount's auto-doc.
* ConfirmLinkSecondaryAuthenticationProvider will filter out requests
  that can no longer be used (i.e. if it was for linking the account
  that got used for creation).
* All the complicated code in AuthManager::beginAccountCreation() was
  trying to deal with allowing the client to pass only the
  CreateFromLoginAuthenticationRequest. That was dumb, removed it.
* Added methods to CreateFromLoginAuthenticationRequest to indicate its
  status with respect to different kinds of preserved state.
* Increase accuracy of the AuthenticationResponse::$createRequest doc.

Change-Id: I726d79de18e739d6e60c1eea51453433c21ba207
2016-05-31 11:44:02 -04:00
Brad Jorsch
d245bd25ae Add AuthManager
This implements the AuthManager class and its needed interfaces and
subclasses, and integrates them into the backend portion of MediaWiki.
Integration with frontend portions of MediaWiki (e.g. ApiLogin,
Special:Login) is left for a followup.

Bug: T91699
Bug: T71589
Bug: T111299
Co-Authored-By: Gergő Tisza <gtisza@wikimedia.org>
Change-Id: If89d24838e326fe25fe867d02181eebcfbb0e196
2016-05-16 15:11:02 +00:00