43 if ( !isset( $params[
'sessionCookieName'] ) ) {
44 $params[
'sessionCookieName'] =
'_BPsession';
46 parent::__construct( $params );
48 if ( !isset( $params[
'priority'] ) ) {
49 throw new \InvalidArgumentException( __METHOD__ .
': priority must be specified' );
54 throw new \InvalidArgumentException( __METHOD__ .
': Invalid priority' );
57 $this->priority = $params[
'priority'];
62 if ( !defined(
'MW_API' ) ) {
67 if ( !$this->config->get(
'EnableBotPasswords' ) ) {
102 'persisted' => $id !==
null,
110 $session = $this->
getManager()->getSessionFromInfo( $info, $request );
120 $missingKeys = array_diff(
121 [
'centralId',
'appId',
'token' ],
122 array_keys( $metadata )
124 if ( $missingKeys ) {
125 $this->logger->info(
'Session "{session}": Missing metadata: {missing}', [
127 'missing' => implode(
', ', $missingKeys ),
135 'Session "{session}": No BotPassword for {centralId} {appId}',
138 'centralId' => $metadata[
'centralId'],
139 'appId' => $metadata[
'appId'],
144 if ( !hash_equals( $metadata[
'token'], $bp->getToken() ) ) {
145 $this->logger->info(
'Session "{session}": BotPassword token check failed', [
147 'centralId' => $metadata[
'centralId'],
148 'appId' => $metadata[
'appId'],
153 $status = $bp->getRestrictions()->check( $request );
154 if ( !$status->isOK() ) {
156 'Session "{session}": Restrictions check failed',
159 'restrictions' => $status->getValue(),
160 'centralId' => $metadata[
'centralId'],
161 'appId' => $metadata[
'appId'],
167 $metadata[
'rights'] = \MWGrants::getGrantRights( $bp->getGrants() );
182 throw new \InvalidArgumentException(
'Backend\'s provider isn\'t $this' );
185 if ( $data && isset( $data[
'rights'] ) && is_array( $data[
'rights'] ) ) {
186 return $data[
'rights'];
190 $this->logger->debug( __METHOD__ .
': No provider metadata, returning no rights allowed' );
Utility class for bot passwords.
getUserCentralId()
Get the central user ID.
getGrants()
Get the grants.
getAppId()
Get the app ID.
static newFromCentralId( $centralId, $appId, $flags=self::READ_NORMAL)
Load a BotPassword from the database.
static removeAllPasswordsForUser( $username)
Remove all passwords for a user, by name.
static getGrantRights( $grants)
Fetch the rights allowed by a set of grants.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...