diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 85f54f3cac..8b545f3767 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -2188,6 +2188,7 @@ phutil_register_library_map(array( 'PhabricatorAuthAuthFactorPHIDType' => 'applications/auth/phid/PhabricatorAuthAuthFactorPHIDType.php', 'PhabricatorAuthAuthProviderPHIDType' => 'applications/auth/phid/PhabricatorAuthAuthProviderPHIDType.php', 'PhabricatorAuthChallenge' => 'applications/auth/storage/PhabricatorAuthChallenge.php', + 'PhabricatorAuthChallengeGarbageCollector' => 'applications/auth/garbagecollector/PhabricatorAuthChallengeGarbageCollector.php', 'PhabricatorAuthChallengePHIDType' => 'applications/auth/phid/PhabricatorAuthChallengePHIDType.php', 'PhabricatorAuthChallengeQuery' => 'applications/auth/query/PhabricatorAuthChallengeQuery.php', 'PhabricatorAuthChangePasswordAction' => 'applications/auth/action/PhabricatorAuthChangePasswordAction.php', @@ -7830,6 +7831,7 @@ phutil_register_library_map(array( 'PhabricatorAuthDAO', 'PhabricatorPolicyInterface', ), + 'PhabricatorAuthChallengeGarbageCollector' => 'PhabricatorGarbageCollector', 'PhabricatorAuthChallengePHIDType' => 'PhabricatorPHIDType', 'PhabricatorAuthChallengeQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorAuthChangePasswordAction' => 'PhabricatorSystemAction', diff --git a/src/applications/auth/garbagecollector/PhabricatorAuthChallengeGarbageCollector.php b/src/applications/auth/garbagecollector/PhabricatorAuthChallengeGarbageCollector.php new file mode 100644 index 0000000000..8a715cb178 --- /dev/null +++ b/src/applications/auth/garbagecollector/PhabricatorAuthChallengeGarbageCollector.php @@ -0,0 +1,28 @@ +establishConnection('w'); + + queryfx( + $conn, + 'DELETE FROM %R WHERE challengeTTL < UNIX_TIMESTAMP() LIMIT 100', + $challenge_table); + + return ($conn->getAffectedRows() == 100); + } + +} diff --git a/src/applications/auth/storage/PhabricatorAuthChallenge.php b/src/applications/auth/storage/PhabricatorAuthChallenge.php index 883aad475a..4ef2a7054f 100644 --- a/src/applications/auth/storage/PhabricatorAuthChallenge.php +++ b/src/applications/auth/storage/PhabricatorAuthChallenge.php @@ -25,6 +25,9 @@ final class PhabricatorAuthChallenge 'key_issued' => array( 'columns' => array('userPHID', 'challengeTTL'), ), + 'key_collection' => array( + 'columns' => array('challengeTTL'), + ), ), ) + parent::getConfiguration(); }