MediaWiki REL1_34
OATHAuth.php
Go to the documentation of this file.
1<?php
2
4
7use Config;
8
14class OATHAuth {
15 const AUTHENTICATED_OVER_2FA = 'OATHAuthAuthenticatedOver2FA';
16
20 protected $config;
24 protected $dbLBFactory;
25
29 protected $modules = [];
30
35 public function __construct( $config, $dbLBFactory ) {
36 $this->config = $config;
37 $this->dbLBFactory = $dbLBFactory;
38 }
39
44 public function getModuleByKey( $key ) {
45 $this->collectModules();
46 if ( isset( $this->modules[$key] ) ) {
47 $module = call_user_func_array( $this->modules[$key], [] );
48 if ( $module instanceof IModule === false ) {
49 return null;
50 }
51 return $module;
52 }
53
54 return null;
55 }
56
62 public function getAllModules() {
63 $this->collectModules();
64 $modules = [];
65 foreach ( $this->modules as $key => $callback ) {
66 $module = $this->getModuleByKey( $key );
67 if ( $module === null || !( $module instanceof IModule ) ) {
68 continue;
69 }
70 $modules[$key] = $module;
71 }
72 return $modules;
73 }
74
75 private function collectModules() {
76 $this->modules = ExtensionRegistry::getInstance()->getAttribute( 'OATHAuthModules' );
77 }
78}
ExtensionRegistry class.
getAllModules()
Get all modules registered on the wiki.
Definition OATHAuth.php:62
__construct( $config, $dbLBFactory)
Definition OATHAuth.php:35
An interface for generating database load balancers.
Definition LBFactory.php:40
Interface for configuration instances.
Definition Config.php:28
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...