Page MenuHomePhabricator
Paste P3303

(An Untitled Masterwork)
ActivePublic

Authored by Tgr on Jun 23 2016, 11:22 AM.
Tags
None
Referenced Files
F4194692:
Jun 23 2016, 11:22 AM
Subscribers
None
class ExampleSessionProvider extends \MediaWiki\Session\ImmutableSessionProviderWithCookie {
public function provideSessionInfo( WebRequest $request ) {
global $egIpUserMap;
$ip = $request->getIp();
if ( isset( $egIpUserMap[$ip] ) ) {
$user = User::newFromName( $egIpUserMap[$ip] );
if ( $this->sessionCookieName === null ) {
$id = \MWCryptHash::hmac( $this . wfWikiID() . $user->getName() . $this->config->get( 'SecretKey' ), false );
$persisted = false;
$forceUse = true;
} else {
$id = $this->getSessionIdFromCookie( $request );
$persisted = $id !== null;
$forceUse = false;
}
return new SessionInfo( SessionInfo::MAX_PRIORITY, [
'provider' => $this,
'id' => $id,
'userInfo' => UserInfo::newFromUser( $user, true ),
'persisted' => $persisted,
'forceUse' => $forceUse,
] );
}
}
}