Go to the documentation of this file.
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 );
116 $missingKeys = array_diff(
117 [
'centralId',
'appId',
'token' ],
118 array_keys( $metadata )
120 if ( $missingKeys ) {
121 $this->logger->info(
'Session "{session}": Missing metadata: {missing}', [
123 'missing' => implode(
', ', $missingKeys ),
131 'Session "{session}": No BotPassword for {centralId} {appId}',
134 'centralId' => $metadata[
'centralId'],
135 'appId' => $metadata[
'appId'],
140 if ( !hash_equals( $metadata[
'token'], $bp->getToken() ) ) {
141 $this->logger->info(
'Session "{session}": BotPassword token check failed', [
143 'centralId' => $metadata[
'centralId'],
144 'appId' => $metadata[
'appId'],
149 $status = $bp->getRestrictions()->check( $request );
152 'Session "{session}": Restrictions check failed',
155 'restrictions' =>
$status->getValue(),
156 'centralId' => $metadata[
'centralId'],
157 'appId' => $metadata[
'appId'],
178 throw new \InvalidArgumentException(
'Backend\'s provider isn\'t $this' );
181 if ( $data && isset( $data[
'rights'] ) && is_array( $data[
'rights'] ) ) {
182 return $data[
'rights'];
186 $this->logger->debug( __METHOD__ .
': No provider metadata, returning no rights allowed' );
getUserCentralId()
Get the central user ID.
static getGrantRights( $grants)
Fetch the rights allowed by a set of grants.
Utility class for bot passwords.
getAppId()
Get the app ID.
static newFromCentralId( $centralId, $appId, $flags=self::READ_NORMAL)
Load a BotPassword from the database.
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
getGrants()
Get the grants.
static removeAllPasswordsForUser( $username)
Remove all passwords for a user, by name.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...