Skip to content

Commit de69bb2

Browse files
committed
first commit.
0 parents  commit de69bb2

File tree

429 files changed

+48952
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

429 files changed

+48952
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/vendor
2+
composer.phar
3+
composer.lock
4+
.DS_Store

composer.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"name": "laravel/framework",
3+
"description": "The Laravel Framework.",
4+
"keywords": ["framework", "laravel"],
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Taylor Otwell",
9+
"email": "taylorotwell@gmail.com"
10+
}
11+
],
12+
"require": {
13+
"php": ">=5.3.0",
14+
"iron-io/iron_mq": "1.2.*",
15+
"monolog/monolog": "1.3.*",
16+
"swiftmailer/swiftmailer": "4.3.*",
17+
"symfony/browser-kit": "2.2.*",
18+
"symfony/console": "2.2.*",
19+
"symfony/css-selector": "2.2.*",
20+
"symfony/dom-crawler": "2.2.*",
21+
"symfony/event-dispatcher": "2.2.*",
22+
"symfony/finder": "2.2.*",
23+
"symfony/http-foundation": "2.2.*",
24+
"symfony/http-kernel": "2.2.*",
25+
"symfony/process": "2.2.*",
26+
"symfony/routing": "2.2.*",
27+
"symfony/translation": "2.2.*"
28+
},
29+
"require-dev": {
30+
"mockery/mockery": "0.7.2"
31+
},
32+
"autoload": {
33+
"classmap": [
34+
"src/Pheanstalk"
35+
],
36+
"files": [
37+
"src/helpers.php"
38+
],
39+
"psr-0": {
40+
"Illuminate": "src/"
41+
}
42+
},
43+
"extra": {
44+
"branch-alias": {
45+
"dev-master": "4.0-dev"
46+
}
47+
},
48+
"minimum-stability": "dev"
49+
}

phpunit.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit backupGlobals="false"
3+
backupStaticAttributes="false"
4+
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
processIsolation="false"
10+
stopOnFailure="false"
11+
syntaxCheck="false"
12+
>
13+
<testsuites>
14+
<testsuite name="Laravel Test Suite">
15+
<directory>./tests/</directory>
16+
</testsuite>
17+
</testsuites>
18+
</phpunit>

src/Illuminate/Auth/AuthManager.php

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?php namespace Illuminate\Auth;
2+
3+
use Illuminate\Support\Manager;
4+
5+
class AuthManager extends Manager {
6+
7+
/**
8+
* Create a new driver instance.
9+
*
10+
* @param string $driver
11+
* @return mixed
12+
*/
13+
protected function createDriver($driver)
14+
{
15+
$guard = parent::createDriver($driver);
16+
17+
// When using the remember me functionality of the authentication services we
18+
// will need to be set the encryption isntance of the guard, which allows
19+
// secure, encrypted cookie values to get generated for those cookies.
20+
$guard->setCookieJar($this->app['cookie']);
21+
22+
$guard->setDispatcher($this->app['events']);
23+
24+
return $guard;
25+
}
26+
27+
/**
28+
* Create an instance of the database driver.
29+
*
30+
* @return Illuminate\Auth\Guard
31+
*/
32+
protected function createDatabaseDriver()
33+
{
34+
$provider = $this->createDatabaseProvider();
35+
36+
return new Guard($provider, $this->app['session']);
37+
}
38+
39+
/**
40+
* Create an instance of the database user provider.
41+
*
42+
* @return Illuminate\Auth\DatabaseUserProvider
43+
*/
44+
protected function createDatabaseProvider()
45+
{
46+
$connection = $this->app['db']->connection();
47+
48+
// When using the basic database user provider, we need to inject the table we
49+
// want to use, since this is not an Eloquent model we will have no way to
50+
// know without telling the provider, so we'll inject the config value.
51+
$table = $this->app['config']['auth.table'];
52+
53+
return new DatabaseUserProvider($connection, $this->app['hash'], $table);
54+
}
55+
56+
/**
57+
* Create an instance of the Eloquent driver.
58+
*
59+
* @return Illuminate\Auth\Guard
60+
*/
61+
public function createEloquentDriver()
62+
{
63+
$provider = $this->createEloquentProvider();
64+
65+
return new Guard($provider, $this->app['session']);
66+
}
67+
68+
/**
69+
* Create an instance of the Eloquent user provider.
70+
*
71+
* @return Illuminate\Auth\EloquentUserProvider
72+
*/
73+
protected function createEloquentProvider()
74+
{
75+
$model = $this->app['config']['auth.model'];
76+
77+
return new EloquentUserProvider($this->app['hash'], $model);
78+
}
79+
80+
/**
81+
* Get the default authentication driver name.
82+
*
83+
* @return string
84+
*/
85+
protected function getDefaultDriver()
86+
{
87+
return $this->app['config']['auth.driver'];
88+
}
89+
90+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?php namespace Illuminate\Auth;
2+
3+
use Illuminate\Support\ServiceProvider;
4+
5+
class AuthServiceProvider extends ServiceProvider {
6+
7+
/**
8+
* Indicates if loading of the provider is deferred.
9+
*
10+
* @var bool
11+
*/
12+
protected $defer = true;
13+
14+
/**
15+
* Bootstrap the application events.
16+
*
17+
* @return void
18+
*/
19+
public function boot()
20+
{
21+
$this->registerAuthEvents();
22+
}
23+
24+
/**
25+
* Register the service provider.
26+
*
27+
* @return void
28+
*/
29+
public function register()
30+
{
31+
$this->app['auth'] = $this->app->share(function($app)
32+
{
33+
// Once the authentication service has actually been requested by the developer
34+
// we will set a variable in the application indicating such. This helps us
35+
// know that we need to set any queued cookies in the after event later.
36+
$app['auth.loaded'] = true;
37+
38+
return new AuthManager($app);
39+
});
40+
}
41+
42+
/**
43+
* Register the events needed for authentication.
44+
*
45+
* @return void
46+
*/
47+
protected function registerAuthEvents()
48+
{
49+
$app = $this->app;
50+
51+
$app->after(function($request, $response) use ($app)
52+
{
53+
// If the authentication service has been used, we'll check for any cookies
54+
// that may be queued by the service. These cookies are all queued until
55+
// they are attached onto Response objects at the end of the requests.
56+
if (isset($app['auth.loaded']))
57+
{
58+
foreach ($app['auth']->getDrivers() as $driver)
59+
{
60+
foreach ($driver->getQueuedCookies() as $cookie)
61+
{
62+
$response->headers->setCookie($cookie);
63+
}
64+
}
65+
}
66+
});
67+
}
68+
69+
/**
70+
* Get the services provided by the provider.
71+
*
72+
* @return array
73+
*/
74+
public function provides()
75+
{
76+
return array('auth');
77+
}
78+
79+
}
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<?php namespace Illuminate\Auth;
2+
3+
use Illuminate\Database\Connection;
4+
use Illuminate\Hashing\HasherInterface;
5+
6+
class DatabaseUserProvider implements UserProviderInterface {
7+
8+
/**
9+
* The active database connection.
10+
*
11+
* @param Illuminate\Database\Connection
12+
*/
13+
protected $conn;
14+
15+
/**
16+
* The hasher implementation.
17+
*
18+
* @var Illuminate\Hashing\HasherInterface
19+
*/
20+
protected $hasher;
21+
22+
/**
23+
* The table containing the users.
24+
*
25+
* @var string
26+
*/
27+
protected $table;
28+
29+
/**
30+
* Create a new database user provider.
31+
*
32+
* @param Illuminate\Database\Connection $conn
33+
* @param Illuminate\Hashing\HasherInterface $hasher
34+
* @param string $table
35+
* @return void
36+
*/
37+
public function __construct(Connection $conn, HasherInterface $hasher, $table)
38+
{
39+
$this->conn = $conn;
40+
$this->table = $table;
41+
$this->hasher = $hasher;
42+
}
43+
44+
/**
45+
* Retrieve a user by their unique idenetifier.
46+
*
47+
* @param mixed $identifier
48+
* @return Illuminate\Auth\UserInterface|null
49+
*/
50+
public function retrieveByID($identifier)
51+
{
52+
$user = $this->conn->table($this->table)->find($identifier);
53+
54+
if ( ! is_null($user))
55+
{
56+
return new GenericUser((array) $user);
57+
}
58+
}
59+
60+
/**
61+
* Retrieve a user by the given credentials.
62+
*
63+
* @param array $credentials
64+
* @return Illuminate\Auth\UserInterface|null
65+
*/
66+
public function retrieveByCredentials(array $credentials)
67+
{
68+
// First we will add each credential element to the query as a where clause.
69+
// Then we can execute the query and, if we found a user, return it in a
70+
// generic "user" object that will be utilized by the Guard instances.
71+
$query = $this->conn->table($this->table);
72+
73+
foreach ($credentials as $key => $value)
74+
{
75+
if ( ! str_contains($key, 'password'))
76+
{
77+
$query->where($key, $value);
78+
}
79+
}
80+
81+
// Now we are ready to execute the query to see if we have an user matching
82+
// the given credentials. If not, we will just return nulls and indicate
83+
// that there are no matching users for these given credential arrays.
84+
$user = $query->first();
85+
86+
if ( ! is_null($user))
87+
{
88+
return new GenericUser((array) $user);
89+
}
90+
}
91+
92+
/**
93+
* Validate a user against the given credentials.
94+
*
95+
* @param Illuminate\Auth\UserInterface $user
96+
* @param array $credentials
97+
* @return bool
98+
*/
99+
public function validateCredentials(UserInterface $user, array $credentials)
100+
{
101+
$plain = $credentials['password'];
102+
103+
return $this->hasher->check($plain, $user->getAuthPassword());
104+
}
105+
106+
}

0 commit comments

Comments
 (0)