MediaWiki  1.34.0
SecondaryAuthenticationProvider.php
Go to the documentation of this file.
1 <?php
2 
4 
11 use User;
12 
20  public function getAuthenticationRequests( $action, array $options ) {
21  return [];
22  }
23 
30  public function beginSecondaryAccountCreation( $user, $creator, array $reqs ) {
32  }
33 
42  public function beginSecondaryAuthentication( $user, array $reqs ) {
43  $authUser = MediaWikiServices::getInstance()->getService( 'OATHUserRepository' )
44  ->findByUser( $user );
45 
46  $module = $authUser->getModule();
47  if ( $module === null ) {
49  }
50 
51  $provider = $this->getProviderForModule( $module );
52  return $provider->beginSecondaryAuthentication( $user, $reqs );
53  }
54 
59  public function continueSecondaryAuthentication( $user, array $reqs ) {
60  $authUser = MediaWikiServices::getInstance()->getService( 'OATHUserRepository' )
61  ->findByUser( $user );
62 
63  $module = $authUser->getModule();
64  $provider = $this->getProviderForModule( $module );
65  $response = $provider->continueSecondaryAuthentication( $user, $reqs );
66  if ( $response->status === AuthenticationResponse::PASS ) {
67  $user->getRequest()->getSession()->set( OATHAuth::AUTHENTICATED_OVER_2FA, true );
68  }
69  return $response;
70  }
71 
76  private function getProviderForModule( IModule $module ) {
77  $provider = $module->getSecondaryAuthProvider();
78  $provider->setLogger( $this->logger );
79  $provider->setManager( $this->manager );
80  $provider->setConfig( $this->config );
81  return $provider;
82  }
83 }
MediaWiki\Auth\AbstractSecondaryAuthenticationProvider
A base class that implements some of the boilerplate for a SecondaryAuthenticationProvider.
Definition: AbstractSecondaryAuthenticationProvider.php:30
$response
$response
Definition: opensearch_desc.php:38
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:117
MediaWiki\Extension\OATHAuth\IModule\getSecondaryAuthProvider
getSecondaryAuthProvider()
MediaWiki\Extension\OATHAuth\Auth\SecondaryAuthenticationProvider\getAuthenticationRequests
getAuthenticationRequests( $action, array $options)
Definition: SecondaryAuthenticationProvider.php:20
MediaWiki\Extension\OATHAuth\Auth\SecondaryAuthenticationProvider
Definition: SecondaryAuthenticationProvider.php:13
MediaWiki\Extension\OATHAuth\Auth\SecondaryAuthenticationProvider\getProviderForModule
getProviderForModule(IModule $module)
Definition: SecondaryAuthenticationProvider.php:76
MediaWiki\Extension\OATHAuth\Auth
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...
Definition: SecondaryAuthenticationProvider.php:3
MediaWiki\Extension\OATHAuth\OATHAuth\AUTHENTICATED_OVER_2FA
const AUTHENTICATED_OVER_2FA
Definition: OATHAuth.php:15
MediaWiki\Extension\OATHAuth\Auth\SecondaryAuthenticationProvider\beginSecondaryAuthentication
beginSecondaryAuthentication( $user, array $reqs)
If the user has enabled two-factor authentication, request a second factor.
Definition: SecondaryAuthenticationProvider.php:42
MediaWiki\MediaWikiServices\getInstance
static getInstance()
Returns the global default instance of the top level service locator.
Definition: MediaWikiServices.php:138
MediaWiki\Auth\AuthenticationResponse\newAbstain
static newAbstain()
Definition: AuthenticationResponse.php:170
MediaWiki\Extension\OATHAuth\OATHAuth
Definition: OATHAuth.php:14
MediaWiki\Extension\OATHAuth\Auth\SecondaryAuthenticationProvider\continueSecondaryAuthentication
continueSecondaryAuthentication( $user, array $reqs)
Verify the second factor.
Definition: SecondaryAuthenticationProvider.php:59
MediaWiki\Auth\AuthenticationResponse
This is a value object to hold authentication response data.
Definition: AuthenticationResponse.php:37
MediaWiki\Extension\OATHAuth\Auth\SecondaryAuthenticationProvider\beginSecondaryAccountCreation
beginSecondaryAccountCreation( $user, $creator, array $reqs)
Definition: SecondaryAuthenticationProvider.php:30
MediaWiki\$action
string $action
Cache what action this request is.
Definition: MediaWiki.php:48
MediaWiki\Auth\AuthenticationResponse\PASS
const PASS
Indicates that the authentication succeeded.
Definition: AuthenticationResponse.php:39
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:51
MediaWiki\Auth\AuthenticationRequest
This is a value object for authentication requests.
Definition: AuthenticationRequest.php:37
MediaWiki\Extension\OATHAuth\IModule
Definition: IModule.php:9