/usr/share/mediawiki-extensions/openid/MemcachedStore.php is in mediawiki-extensions-openid 3.6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | <?php
require_once( 'Auth/OpenID/MemcachedStore.php' );
class MediaWikiOpenIDMemcachedStore extends Auth_OpenID_MemcachedStore {
function __construct( $connection ) {
$this->connection = $connection;
}
function storeAssociation( $server_url, $association ) {
$associationKey = $this->associationKey( $server_url,
$association->handle );
$serverKey = $this->associationServerKey( $server_url );
$serverAssociations = $this->connection->get( $serverKey );
if ( !$serverAssociations ) {
$serverAssociations = array();
}
$serverAssociations[$association->issued] = $associationKey;
$this->connection->set( $serverKey, $serverAssociations );
$this->connection->set( $associationKey, $association,
$association->issued + $association->lifetime );
}
function getAssociation( $server_url, $handle = null ) {
if ( $handle !== null ) {
$association = $this->connection->get(
$this->associationKey( $server_url, $handle ) );
return $association ? $association : null;
}
$serverKey = $this->associationServerKey( $server_url );
$serverAssociations = $this->connection->get( $serverKey );
if ( !$serverAssociations ) {
return null;
}
$keys = array_keys( $serverAssociations );
sort( $keys );
$lastKey = $serverAssociations[array_pop( $keys )];
$association = $this->connection->get( $lastKey );
return $association ? $association : null;
}
function removeAssociation( $server_url, $handle ) {
$serverKey = $this->associationServerKey( $server_url );
$associationKey = $this->associationKey( $server_url,
$handle );
$serverAssociations = $this->connection->get( $serverKey );
if ( !$serverAssociations ) {
return false;
}
$serverAssociations = array_flip( $serverAssociations );
if ( !array_key_exists( $associationKey, $serverAssociations ) ) {
return false;
}
unset( $serverAssociations[$associationKey] );
$serverAssociations = array_flip( $serverAssociations );
$this->connection->set( $serverKey, $serverAssociations );
return $this->connection->delete( $associationKey );
}
function useNonce( $server_url, $timestamp, $salt ) {
global $Auth_OpenID_SKEW;
if ( abs( $timestamp - time() ) > $Auth_OpenID_SKEW ) {
return false;
}
return $this->connection->add(
'openid_nonce_' . sha1( $server_url ) . '_' . sha1( $salt ),
1, $Auth_OpenID_SKEW );
}
}
|