Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
Added blocking and regular expressions for domains.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelchisari authored and The Appleseed Project committed Dec 28, 2010
1 parent f449142 commit 0dd00f1
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 5 deletions.
2 changes: 2 additions & 0 deletions components/login/languages/en-US/login.lang
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ INVALID_CALLBACK="A system error occurred: Invalid Callback."
INVALID_NODE="This is not a valid Appleseed node."
NOT_LOGGED_IN_TO_NODE="You are not logged in to this Appleseed node."

BLOCKED_NODE="This node has been blocked by the Administrator. "

[password_reset]
PASSWORD_RESET_CLICK_HERE="Click here to login:"
PASSWORD_RESET_FROM="password@%domain$s"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function ReplyToSynchronize ( ) {

$verified = $this->Verify ( null, $source, $token );
if ( $verified->success != 'true' ) {
$this->_Error ( "Invalid Token" );
$this->_Error ( 'Invalid Node' );
exit;
}

Expand Down
15 changes: 15 additions & 0 deletions hooks/quicksocial/libraries/QuickSocial-0.1.0/quicksocial.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,21 @@ public function ReplyToRemoteVerify ( ) {

}

public function Blocked ( ) {

$fCheckBlocked = $this->GetCallback ( 'CheckBlocked' );

if ( !is_callable ( $fCheckBlocked ) ) $this->_Error ( 'Invalid Callback: CheckBlocked' );

$source = $this->_GET['_source'];

$result = @call_user_func ( $fCheckBlocked, $source );

if ( !$result ) $this->_Error ( 'Blocked' );

return ( true );
}

protected function _Error ( $pError ) {

$return = array (
Expand Down
31 changes: 27 additions & 4 deletions hooks/quicksocial/quicksocial.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,24 @@ public function EndSystemInitialize ( $pData = null ) {

if ( $social != 'true' ) return ( false );

require ( ASD_PATH . 'hooks' . DS . 'quicksocial' . DS . 'libraries' . DS . 'QuickSocial-0.1.0' . DS . 'quicksocial.php' );

$social = new cQuickSocial ();
$social->SetCallback ( 'CheckBlocked', array ( $this, '_CheckBlocked' ) );

$social->Blocked();

$task = $this->GetSys ( 'Request' )->Get ( '_task' );

switch ( $task ) {
case 'verify':
require ( ASD_PATH . 'hooks' . DS . 'quicksocial' . DS . 'libraries' . DS . 'QuickSocial-0.1.0' . DS . 'quicksocial.php' );

$social = new cQuickSocial ();
$social->SetCallback ( 'CheckLocalToken', array ( $this, '_CheckLocalToken' ) );

$social->ReplyToVerify();
exit;
break;
case 'verify.remote':
require ( ASD_PATH . 'hooks' . DS . 'quicksocial' . DS . 'libraries' . DS . 'QuickSocial-0.1.0' . DS . 'quicksocial.php' );

$social = new cQuickSocial ();
$social->SetCallback ( 'CheckLocalToken', array ( $this, '_CheckLocalToken' ) );

Expand Down Expand Up @@ -187,6 +190,20 @@ public function EndSystemInitialize ( $pData = null ) {

}

public function _CheckBlocked ( $pSource ) {

list ( $trusted, $discovered, $blocked ) = $this->_LoadNodeNetwork ( );

foreach ( $blocked as $b => $block ) {
$pattern = '/^' . $block . '$/';
if ( preg_match ( $pattern, $pSource ) ) {
return ( false );
}
}

return ( true );
}

public function OnLoginAuthenticate ( $pData ) {

if (!class_exists ( 'cQuickNode' ) ) require ( ASD_PATH . 'hooks' . DS . 'quicksocial' . DS . 'libraries' . DS . 'QuickSocial-0.1.0' . DS . 'quicknode.php' );
Expand All @@ -195,6 +212,12 @@ public function OnLoginAuthenticate ( $pData ) {

$domain = $pData['domain'];

if ( !$this->_CheckBlocked ( $domain ) ) {
$return = new stdClass();
$return->error = 'Blocked Node';
return ( $return );
}

$node->SetCallback ( 'CheckLocalToken', array ( $this, '_CheckLocalToken' ) );
$node->SetCallback ( 'CreateLocalToken', array ( $this, '_CreateLocalToken' ) );
$node->SetCallback ( 'LogNetworkRequest', array ( $this, '_LogNetworkRequest' ) );
Expand Down

0 comments on commit 0dd00f1

Please sign in to comment.