diff options
author | Max Magorsch <arzano@gentoo.org> | 2020-05-27 02:30:01 +0200 |
---|---|---|
committer | Max Magorsch <arzano@gentoo.org> | 2020-05-27 02:30:01 +0200 |
commit | 881c1e396ad9ace944b022394fdda1d1d95d3b51 (patch) | |
tree | ce22601f07aa36fb5ee31a28d9075c6163887153 /PluggableAuth/includes/PluggableAuth.php | |
parent | Add OpenIDConnect extension for Gentoo SSO (diff) | |
download | extensions-881c1e396ad9ace944b022394fdda1d1d95d3b51.tar.gz extensions-881c1e396ad9ace944b022394fdda1d1d95d3b51.tar.bz2 extensions-881c1e396ad9ace944b022394fdda1d1d95d3b51.zip |
Add PluggableAuth extension for OpenID Connect
Signed-off-by: Max Magorsch <arzano@gentoo.org>
Diffstat (limited to 'PluggableAuth/includes/PluggableAuth.php')
-rw-r--r-- | PluggableAuth/includes/PluggableAuth.php | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/PluggableAuth/includes/PluggableAuth.php b/PluggableAuth/includes/PluggableAuth.php new file mode 100644 index 00000000..8ecf4e40 --- /dev/null +++ b/PluggableAuth/includes/PluggableAuth.php @@ -0,0 +1,54 @@ +<?php + +abstract class PluggableAuth { + + /** + * @since 1.0 + * + * @param int &$id The user's user ID + * @param string &$username The user's user name + * @param string &$realname The user's real name + * @param string &$email The user's email address + * @param string &$errorMessage Returns a descritive message if + * there's an error + */ + abstract public function authenticate( &$id, &$username, &$realname, + &$email, &$errorMessage ); + + /** + * @since 1.0 + * + * @param User &$user The user + */ + abstract public function deauthenticate( User &$user ); + + /** + * @since 1.0 + * + * @param int $id The user's user ID + */ + abstract public function saveExtraAttributes( $id ); + + private static $instance = null; + + /** + * @since 2.0 + * @return PluggableAuth a PluggableAuth object + */ + public static function singleton() { + wfDebugLog( 'PluggableAuth', 'Getting PluggableAuth singleton' ); + wfDebugLog( 'PluggableAuth', 'Class name: ' . $GLOBALS['wgPluggableAuth_Class'] ); + if ( !is_null( self::$instance ) ) { + wfDebugLog( 'PluggableAuth', 'Singleton already exists' ); + return self::$instance; + } elseif ( isset( $GLOBALS['wgPluggableAuth_Class'] ) && + class_exists( $GLOBALS['wgPluggableAuth_Class'] ) && + is_subclass_of( $GLOBALS['wgPluggableAuth_Class'], + 'PluggableAuth' ) ) { + self::$instance = new $GLOBALS['wgPluggableAuth_Class']; + return self::$instance; + } + wfDebugLog( 'PluggableAuth', 'Could not get authentication plugin instance.' ); + return false; + } +} |