Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
@@ -64,11 +64,12 @@ class _Handler extends \IPS\MFA\MFAHandler
|
||||
/**
|
||||
* Show a setup screen
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param \IPS\Member $member The member
|
||||
* @param bool $showingMultipleHandlers Set to TRUE if multiple options are being displayed
|
||||
* @param \IPS\Http\Url $url URL for page
|
||||
* @return string
|
||||
*/
|
||||
public function configurationScreen( \IPS\Member $member, $showingMultipleHandlers = FALSE )
|
||||
public function configurationScreen( \IPS\Member $member, $showingMultipleHandlers=FALSE, \IPS\Http\Url $url )
|
||||
{
|
||||
$mfaDetails = $member->mfa_details;
|
||||
|
||||
@@ -112,7 +113,7 @@ class _Handler extends \IPS\MFA\MFAHandler
|
||||
}
|
||||
|
||||
/* Display */
|
||||
return \IPS\Theme::i()->getTemplate( 'login', 'core', 'global' )->authyAuthenticate( $mfaDetails['authy']['setupMethod'], TRUE, isset( $_SESSION['authyAuthError'] ) ? $_SESSION['authyAuthError'] : 'authy_error', TRUE, explode( ',', \IPS\Settings::i()->authy_setup ) );
|
||||
return \IPS\Theme::i()->getTemplate( 'login', 'core', 'global' )->authyAuthenticate( $mfaDetails['authy']['setupMethod'], TRUE, isset( $_SESSION['authyAuthError'] ) ? $_SESSION['authyAuthError'] : 'authy_error', TRUE, explode( ',', \IPS\Settings::i()->authy_setup ), NULL, $url );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -277,10 +278,11 @@ class _Handler extends \IPS\MFA\MFAHandler
|
||||
/**
|
||||
* Get the form for a member to authenticate
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param \IPS\Member $member The member
|
||||
* @param \IPS\Http\Url $url URL for page
|
||||
* @return string
|
||||
*/
|
||||
public function authenticationScreen( \IPS\Member $member )
|
||||
public function authenticationScreen( \IPS\Member $member, \IPS\Http\Url $url )
|
||||
{
|
||||
$mfaDetails = $member->mfa_details;
|
||||
$availableMethods = explode( ',', \IPS\Settings::i()->authy_method );
|
||||
@@ -334,7 +336,7 @@ class _Handler extends \IPS\MFA\MFAHandler
|
||||
}
|
||||
if ( isset( $mfaDetails['authy']['sent'] ) )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'login', 'core', 'global' )->authyAuthenticate( $mfaDetails['authy']['sent']['method'], TRUE, isset( $_SESSION['authyAuthError'] ) ? $_SESSION['authyAuthError'] : 'authy_error', FALSE, $availableMethods );
|
||||
return \IPS\Theme::i()->getTemplate( 'login', 'core', 'global' )->authyAuthenticate( $mfaDetails['authy']['sent']['method'], TRUE, isset( $_SESSION['authyAuthError'] ) ? $_SESSION['authyAuthError'] : 'authy_error', FALSE, $availableMethods, NULL, $url );
|
||||
}
|
||||
|
||||
/* Otherwise, check if they have the app installed. If they do, show the Authy authenticate page */
|
||||
@@ -352,7 +354,7 @@ class _Handler extends \IPS\MFA\MFAHandler
|
||||
|
||||
if ( $userHasAuthyApp )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'login', 'core', 'global' )->authyAuthenticate( 'authy', TRUE, isset( $_SESSION['authyAuthError'] ) ? $_SESSION['authyAuthError'] : 'authy_error', FALSE, $availableMethods, $this->_onetouchInit( $member ) );
|
||||
return \IPS\Theme::i()->getTemplate( 'login', 'core', 'global' )->authyAuthenticate( 'authy', TRUE, isset( $_SESSION['authyAuthError'] ) ? $_SESSION['authyAuthError'] : 'authy_error', FALSE, $availableMethods, $this->_onetouchInit( $member, $url ), $url );
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e ) { }
|
||||
@@ -361,7 +363,7 @@ class _Handler extends \IPS\MFA\MFAHandler
|
||||
/* If it is the only option, show it anyway */
|
||||
else
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'login', 'core', 'global' )->authyAuthenticate( 'authy', TRUE, isset( $_SESSION['authyAuthError'] ) ? $_SESSION['authyAuthError'] : 'authy_error', FALSE, $availableMethods, $this->_onetouchInit( $member ) );
|
||||
return \IPS\Theme::i()->getTemplate( 'login', 'core', 'global' )->authyAuthenticate( 'authy', TRUE, isset( $_SESSION['authyAuthError'] ) ? $_SESSION['authyAuthError'] : 'authy_error', FALSE, $availableMethods, $this->_onetouchInit( $member, $url ), $url );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -387,7 +389,7 @@ class _Handler extends \IPS\MFA\MFAHandler
|
||||
}
|
||||
|
||||
/* Show screen */
|
||||
return \IPS\Theme::i()->getTemplate( 'login', 'core', 'global' )->authyAuthenticate( 'sms', TRUE, isset( $_SESSION['authyAuthError'] ) ? $_SESSION['authyAuthError'] : 'authy_error', FALSE, $availableMethods );
|
||||
return \IPS\Theme::i()->getTemplate( 'login', 'core', 'global' )->authyAuthenticate( 'sms', TRUE, isset( $_SESSION['authyAuthError'] ) ? $_SESSION['authyAuthError'] : 'authy_error', FALSE, $availableMethods, NULL, $url );
|
||||
}
|
||||
|
||||
/* If we have confirmed the phone call, do that now */
|
||||
@@ -412,24 +414,35 @@ class _Handler extends \IPS\MFA\MFAHandler
|
||||
}
|
||||
|
||||
/* Show screen */
|
||||
return \IPS\Theme::i()->getTemplate( 'login', 'core', 'global' )->authyAuthenticate( 'phone', TRUE, isset( $_SESSION['authyAuthError'] ) ? $_SESSION['authyAuthError'] : 'authy_error', FALSE, $availableMethods );
|
||||
return \IPS\Theme::i()->getTemplate( 'login', 'core', 'global' )->authyAuthenticate( 'phone', TRUE, isset( $_SESSION['authyAuthError'] ) ? $_SESSION['authyAuthError'] : 'authy_error', FALSE, $availableMethods, NULL, $url );
|
||||
}
|
||||
|
||||
/* Otherwise we're going to show a screen */
|
||||
return \IPS\Theme::i()->getTemplate( 'login', 'core', 'global' )->authyAuthenticate( count( $availableMethods ) == 1 ? 'phone' : 'choose', FALSE, isset( $_SESSION['authyAuthError'] ) ? $_SESSION['authyAuthError'] : 'authy_error', FALSE, $availableMethods );
|
||||
return \IPS\Theme::i()->getTemplate( 'login', 'core', 'global' )->authyAuthenticate( count( $availableMethods ) == 1 ? 'phone' : 'choose', FALSE, isset( $_SESSION['authyAuthError'] ) ? $_SESSION['authyAuthError'] : 'authy_error', FALSE, $availableMethods, NULL, $url );
|
||||
}
|
||||
|
||||
/**
|
||||
* If enabled, initiate a OneTouch request and get the ID
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param \IPS\Member $member The member
|
||||
* @param \IPS\Http\Url $url URL for page
|
||||
* @return string|null
|
||||
*/
|
||||
protected function _onetouchInit( \IPS\Member $member )
|
||||
{
|
||||
protected function _onetouchInit( \IPS\Member $member, \IPS\Http\Url $url )
|
||||
{
|
||||
if ( \IPS\Settings::i()->authy_onetouch )
|
||||
{
|
||||
$mfaDetails = $member->mfa_details;
|
||||
|
||||
if ( isset( $mfaDetails['onetouch'] ) and $mfaDetails['onetouch']['time'] > ( time() - 30 ) )
|
||||
{
|
||||
$response = static::onetouch( "approval_requests/" . preg_replace( '/[^A-Z0-9\-]/i', '', $mfaDetails['onetouch']['id'] ), 'get' );
|
||||
|
||||
if ( $response['approval_request']['status'] === 'pending' )
|
||||
{
|
||||
return $mfaDetails['onetouch']['id'];
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
@@ -437,9 +450,17 @@ class _Handler extends \IPS\MFA\MFAHandler
|
||||
'message' => $member->language()->get('authy_onetouch_message'),
|
||||
'seconds_to_expire' => 300
|
||||
) );
|
||||
return $response['approval_request']['uuid'];
|
||||
|
||||
$mfaDetails['onetouch'] = array( 'id' => $response['approval_request']['uuid'], 'time' => time() );
|
||||
$member->mfa_details = $mfaDetails;
|
||||
$member->save();
|
||||
}
|
||||
catch ( \Exception $e ) { }
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return $mfaDetails['onetouch']['id'];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -535,8 +556,7 @@ class _Handler extends \IPS\MFA\MFAHandler
|
||||
static::verifyApiKey( \IPS\Settings::i()->authy_key );
|
||||
}
|
||||
|
||||
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => $enabled ), array( 'conf_key=?', 'authy_enabled' ) );
|
||||
unset( \IPS\Data\Store::i()->settings );
|
||||
\IPS\Settings::i()->changeValues( array( 'authy_enabled' => $enabled ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user