Skip to content

Commit

Permalink
Merge pull request #18 from SaschaDens/analysis-zOPpW8
Browse files Browse the repository at this point in the history
Applied fixes from StyleCI
SaschaDens committed Aug 23, 2015
2 parents 9b1bbd3 + a1035b1 commit 09b4bd2
Showing 7 changed files with 51 additions and 35 deletions.
9 changes: 4 additions & 5 deletions spec/Dsdevbe/LdapConnector/LdapUserProviderSpec.php
Original file line number Diff line number Diff line change
@@ -4,21 +4,20 @@

use Dsdevbe\LdapConnector\Adapter\LdapInterface;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;

class LdapUserProviderSpec extends ObjectBehavior
{
function let(LdapInterface $interface)
public function let(LdapInterface $interface)
{
$this->beConstructedWith($interface);
}

function it_is_initializable()
public function it_is_initializable()
{
$this->shouldHaveType('Dsdevbe\LdapConnector\LdapUserProvider');
}

function it_validate_user_by_credentials(LdapInterface $interface)
public function it_validate_user_by_credentials(LdapInterface $interface)
{
$user = [
'username' => '[email protected]',
@@ -29,7 +28,7 @@ function it_validate_user_by_credentials(LdapInterface $interface)
$this->retrieveByCredentials($user);
}

function it_retrieves_user_by_id(LdapInterface $interface)
public function it_retrieves_user_by_id(LdapInterface $interface)
{
$identifier = '[email protected]';

7 changes: 6 additions & 1 deletion src/Dsdevbe/LdapConnector/Adapter/Adldap.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Dsdevbe\LdapConnector\Adapter;

use adLDAP\adLDAP as adLDAPService;
@@ -19,6 +20,7 @@ protected function mapDataToUserModel($username, array $groups)
'password' => $this->_password,
]);
$model->setGroups($groups);

return $model;
}

@@ -30,6 +32,7 @@ public function __construct($config)
/**
* @param String $username
* @param String $password
*
* @return bool
*/
public function connect($username, $password)
@@ -50,17 +53,19 @@ public function isConnected()

/**
* @param String $username
*
* @return UserModel
*/
public function getUserInfo($username)
{
$user = $this->_ldap->user()->info($username);

if (!$user) {
return null;
return;
}

$groups = $this->_ldap->user()->groups($username);

return $this->mapDataToUserModel($username, $groups);
}
}
3 changes: 3 additions & 0 deletions src/Dsdevbe/LdapConnector/Adapter/LdapInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Dsdevbe\LdapConnector\Adapter;

use Dsdevbe\LdapConnector\Model\User as UserModel;
@@ -8,6 +9,7 @@ interface LdapInterface
/**
* @param String $username
* @param String $password
*
* @return bool
*/
public function connect($username, $password);
@@ -19,6 +21,7 @@ public function isConnected();

/**
* @param $username
*
* @return UserModel
*/
public function getUserInfo($username);
22 changes: 11 additions & 11 deletions src/Dsdevbe/LdapConnector/Config/ldap.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php

return array(
'plugins' => array(
'adldap' => array(
'account_suffix'=> '@domain.local',
'domain_controllers'=> array(
return [
'plugins' => [
'adldap' => [
'account_suffix' => '@domain.local',
'domain_controllers' => [
'192.168.0.1',
'dc02.domain.local'
), // Load balancing domain controllers
'base_dn' => 'DC=domain,DC=local',
'dc02.domain.local',
], // Load balancing domain controllers
'base_dn' => 'DC=domain,DC=local',
'admin_username' => 'admin', // This is required for session persistance in the application
'admin_password' => 'yourPassword',
),
),
);
],
],
];
15 changes: 8 additions & 7 deletions src/Dsdevbe/LdapConnector/LdapConnectorServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Dsdevbe\LdapConnector;

use Auth;
@@ -8,7 +9,6 @@

class LdapConnectorServiceProvider extends ServiceProvider
{

/**
* Indicates if loading of the provider is deferred.
*
@@ -40,7 +40,7 @@ public function boot()
*/
public function register()
{
$ldapConfig = __DIR__ . '/Config/ldap.php';
$ldapConfig = __DIR__.'/Config/ldap.php';
$this->publishConfig($ldapConfig);
}

@@ -51,18 +51,18 @@ public function register()
*/
public function provides()
{
return array('auth');
return ['auth'];
}

protected function publishConfig($configPath)
{
$this->publishes(array(
$configPath => config_path('ldap.php')
));
$this->publishes([
$configPath => config_path('ldap.php'),
]);
}

/**
* Get ldap configuration
* Get ldap configuration.
*
* @return array
*/
@@ -73,6 +73,7 @@ public function getLdapConfig()

/**
* @param $pluginName
*
* @return array
*/
public function getLdapAdapterConfig($pluginName)
25 changes: 16 additions & 9 deletions src/Dsdevbe/LdapConnector/LdapUserProvider.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php namespace Dsdevbe\LdapConnector;
<?php

namespace Dsdevbe\LdapConnector;

use Dsdevbe\LdapConnector\Adapter\LdapInterface;
use Illuminate\Contracts\Auth\Authenticatable;
@@ -19,7 +21,8 @@ public function __construct(LdapInterface $adapter)
/**
* Retrieve a user by their unique identifier.
*
* @param mixed $identifier
* @param mixed $identifier
*
* @return \Illuminate\Contracts\Auth\Authenticatable|null
*/
public function retrieveById($identifier)
@@ -30,8 +33,9 @@ public function retrieveById($identifier)
/**
* Retrieve a user by their unique identifier and "remember me" token.
*
* @param mixed $identifier
* @param string $token
* @param mixed $identifier
* @param string $token
*
* @return \Illuminate\Contracts\Auth\Authenticatable|null
*/
public function retrieveByToken($identifier, $token)
@@ -42,8 +46,9 @@ public function retrieveByToken($identifier, $token)
/**
* Update the "remember me" token for the given user in storage.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param string $token
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param string $token
*
* @return void
*/
public function updateRememberToken(Authenticatable $user, $token)
@@ -54,7 +59,8 @@ public function updateRememberToken(Authenticatable $user, $token)
/**
* Retrieve a user by the given credentials.
*
* @param array $credentials
* @param array $credentials
*
* @return \Illuminate\Contracts\Auth\Authenticatable|null
*/
public function retrieveByCredentials(array $credentials)
@@ -68,8 +74,9 @@ public function retrieveByCredentials(array $credentials)
/**
* Validate a user against the given credentials.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param array $credentials
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param array $credentials
*
* @return bool
*/
public function validateCredentials(Authenticatable $user, array $credentials)
5 changes: 3 additions & 2 deletions src/Dsdevbe/LdapConnector/Model/User.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Dsdevbe\LdapConnector\Model;

use Illuminate\Contracts\Auth\Authenticatable;
@@ -64,7 +65,8 @@ public function getRememberToken()
/**
* Set the token value for the "remember me" session.
*
* @param string $value
* @param string $value
*
* @return void
*/
public function setRememberToken($value)
@@ -97,5 +99,4 @@ public function inGroup($groupName)
{
return in_array($groupName, $this->_groups);
}

}

0 comments on commit 09b4bd2

Please sign in to comment.