MediaWiki REL1_34
SecondaryAuthenticationProvider.php
Go to the documentation of this file.
1<?php
2
4
11use User;
12
20 public function getAuthenticationRequests( $action, array $options ) {
21 return [];
22 }
23
30 public function beginSecondaryAccountCreation( $user, $creator, array $reqs ) {
31 return AuthenticationResponse::newAbstain();
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 ) {
48 return AuthenticationResponse::newAbstain();
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}
A base class that implements some of the boilerplate for a SecondaryAuthenticationProvider.
This is a value object for authentication requests.
This is a value object to hold authentication response data.
beginSecondaryAuthentication( $user, array $reqs)
If the user has enabled two-factor authentication, request a second factor.
MediaWikiServices is the service locator for the application scope of MediaWiki.
static getInstance()
Returns the global default instance of the top level service locator.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition User.php:51
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...