This commit is contained in:
Paolo A
2024-08-13 13:44:16 +00:00
parent 1bbb23088d
commit e796d76612
4001 changed files with 30101 additions and 40075 deletions

View File

@@ -36,7 +36,10 @@ class ArraySessionHandler implements SessionHandlerInterface
/**
* {@inheritdoc}
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function open($savePath, $sessionName)
{
return true;
@@ -44,7 +47,10 @@ class ArraySessionHandler implements SessionHandlerInterface
/**
* {@inheritdoc}
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function close()
{
return true;
@@ -52,7 +58,10 @@ class ArraySessionHandler implements SessionHandlerInterface
/**
* {@inheritdoc}
*
* @return string|false
*/
#[\ReturnTypeWillChange]
public function read($sessionId)
{
if (! isset($this->storage[$sessionId])) {
@@ -72,7 +81,10 @@ class ArraySessionHandler implements SessionHandlerInterface
/**
* {@inheritdoc}
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function write($sessionId, $data)
{
$this->storage[$sessionId] = [
@@ -85,7 +97,10 @@ class ArraySessionHandler implements SessionHandlerInterface
/**
* {@inheritdoc}
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function destroy($sessionId)
{
if (isset($this->storage[$sessionId])) {
@@ -97,7 +112,10 @@ class ArraySessionHandler implements SessionHandlerInterface
/**
* {@inheritdoc}
*
* @return int|false
*/
#[\ReturnTypeWillChange]
public function gc($lifetime)
{
$expiration = $this->calculateExpiration($lifetime);

View File

@@ -36,7 +36,10 @@ class CacheBasedSessionHandler implements SessionHandlerInterface
/**
* {@inheritdoc}
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function open($savePath, $sessionName)
{
return true;
@@ -44,7 +47,10 @@ class CacheBasedSessionHandler implements SessionHandlerInterface
/**
* {@inheritdoc}
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function close()
{
return true;
@@ -52,7 +58,10 @@ class CacheBasedSessionHandler implements SessionHandlerInterface
/**
* {@inheritdoc}
*
* @return string|false
*/
#[\ReturnTypeWillChange]
public function read($sessionId)
{
return $this->cache->get($sessionId, '');
@@ -60,7 +69,10 @@ class CacheBasedSessionHandler implements SessionHandlerInterface
/**
* {@inheritdoc}
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function write($sessionId, $data)
{
return $this->cache->put($sessionId, $data, $this->minutes * 60);
@@ -68,7 +80,10 @@ class CacheBasedSessionHandler implements SessionHandlerInterface
/**
* {@inheritdoc}
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function destroy($sessionId)
{
return $this->cache->forget($sessionId);
@@ -76,7 +91,10 @@ class CacheBasedSessionHandler implements SessionHandlerInterface
/**
* {@inheritdoc}
*
* @return int|false
*/
#[\ReturnTypeWillChange]
public function gc($lifetime)
{
return true;

View File

@@ -14,12 +14,12 @@ class CreateSessionsTable extends Migration
public function up()
{
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->unique();
$table->foreignId('user_id')->nullable();
$table->string('id')->primary();
$table->foreignId('user_id')->nullable()->index();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->text('payload');
$table->integer('last_activity');
$table->integer('last_activity')->index();
});
}

View File

@@ -47,7 +47,10 @@ class CookieSessionHandler implements SessionHandlerInterface
/**
* {@inheritdoc}
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function open($savePath, $sessionName)
{
return true;
@@ -55,7 +58,10 @@ class CookieSessionHandler implements SessionHandlerInterface
/**
* {@inheritdoc}
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function close()
{
return true;
@@ -63,7 +69,10 @@ class CookieSessionHandler implements SessionHandlerInterface
/**
* {@inheritdoc}
*
* @return string|false
*/
#[\ReturnTypeWillChange]
public function read($sessionId)
{
$value = $this->request->cookies->get($sessionId) ?: '';
@@ -79,7 +88,10 @@ class CookieSessionHandler implements SessionHandlerInterface
/**
* {@inheritdoc}
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function write($sessionId, $data)
{
$this->cookie->queue($sessionId, json_encode([
@@ -92,7 +104,10 @@ class CookieSessionHandler implements SessionHandlerInterface
/**
* {@inheritdoc}
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function destroy($sessionId)
{
$this->cookie->queue($this->cookie->forget($sessionId));
@@ -102,7 +117,10 @@ class CookieSessionHandler implements SessionHandlerInterface
/**
* {@inheritdoc}
*
* @return int|false
*/
#[\ReturnTypeWillChange]
public function gc($lifetime)
{
return true;

View File

@@ -69,7 +69,10 @@ class DatabaseSessionHandler implements ExistenceAwareInterface, SessionHandlerI
/**
* {@inheritdoc}
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function open($savePath, $sessionName)
{
return true;
@@ -77,7 +80,10 @@ class DatabaseSessionHandler implements ExistenceAwareInterface, SessionHandlerI
/**
* {@inheritdoc}
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function close()
{
return true;
@@ -85,7 +91,10 @@ class DatabaseSessionHandler implements ExistenceAwareInterface, SessionHandlerI
/**
* {@inheritdoc}
*
* @return string|false
*/
#[\ReturnTypeWillChange]
public function read($sessionId)
{
$session = (object) $this->getQuery()->find($sessionId);
@@ -119,7 +128,10 @@ class DatabaseSessionHandler implements ExistenceAwareInterface, SessionHandlerI
/**
* {@inheritdoc}
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function write($sessionId, $data)
{
$payload = $this->getDefaultPayload($data);
@@ -141,7 +153,7 @@ class DatabaseSessionHandler implements ExistenceAwareInterface, SessionHandlerI
* Perform an insert operation on the session ID.
*
* @param string $sessionId
* @param string $payload
* @param array<string, mixed> $payload
* @return bool|null
*/
protected function performInsert($sessionId, $payload)
@@ -157,7 +169,7 @@ class DatabaseSessionHandler implements ExistenceAwareInterface, SessionHandlerI
* Perform an update operation on the session ID.
*
* @param string $sessionId
* @param string $payload
* @param array<string, mixed> $payload
* @return int
*/
protected function performUpdate($sessionId, $payload)
@@ -253,7 +265,10 @@ class DatabaseSessionHandler implements ExistenceAwareInterface, SessionHandlerI
/**
* {@inheritdoc}
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function destroy($sessionId)
{
$this->getQuery()->where('id', $sessionId)->delete();
@@ -263,7 +278,10 @@ class DatabaseSessionHandler implements ExistenceAwareInterface, SessionHandlerI
/**
* {@inheritdoc}
*
* @return int|false
*/
#[\ReturnTypeWillChange]
public function gc($lifetime)
{
$this->getQuery()->where('last_activity', '<=', $this->currentTime() - $lifetime)->delete();
@@ -279,6 +297,19 @@ class DatabaseSessionHandler implements ExistenceAwareInterface, SessionHandlerI
return $this->connection->table($this->table);
}
/**
* Set the application instance used by the handler.
*
* @param \Illuminate\Contracts\Foundation\Application $container
* @return $this
*/
public function setContainer($container)
{
$this->container = $container;
return $this;
}
/**
* Set the existence state for the session.
*

View File

@@ -47,7 +47,10 @@ class FileSessionHandler implements SessionHandlerInterface
/**
* {@inheritdoc}
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function open($savePath, $sessionName)
{
return true;
@@ -55,7 +58,10 @@ class FileSessionHandler implements SessionHandlerInterface
/**
* {@inheritdoc}
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function close()
{
return true;
@@ -63,7 +69,10 @@ class FileSessionHandler implements SessionHandlerInterface
/**
* {@inheritdoc}
*
* @return string|false
*/
#[\ReturnTypeWillChange]
public function read($sessionId)
{
if ($this->files->isFile($path = $this->path.'/'.$sessionId)) {
@@ -77,7 +86,10 @@ class FileSessionHandler implements SessionHandlerInterface
/**
* {@inheritdoc}
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function write($sessionId, $data)
{
$this->files->put($this->path.'/'.$sessionId, $data, true);
@@ -87,7 +99,10 @@ class FileSessionHandler implements SessionHandlerInterface
/**
* {@inheritdoc}
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function destroy($sessionId)
{
$this->files->delete($this->path.'/'.$sessionId);
@@ -97,7 +112,10 @@ class FileSessionHandler implements SessionHandlerInterface
/**
* {@inheritdoc}
*
* @return int|false
*/
#[\ReturnTypeWillChange]
public function gc($lifetime)
{
$files = Finder::create()

View File

@@ -39,7 +39,7 @@ class AuthenticateSession
return $next($request);
}
if ($this->auth->viaRemember()) {
if ($this->guard()->viaRemember()) {
$passwordHash = explode('|', $request->cookies->get($this->auth->getRecallerName()))[2] ?? null;
if (! $passwordHash || $passwordHash != $request->user()->getAuthPassword()) {
@@ -47,16 +47,18 @@ class AuthenticateSession
}
}
if (! $request->session()->has('password_hash')) {
if (! $request->session()->has('password_hash_'.$this->auth->getDefaultDriver())) {
$this->storePasswordHashInSession($request);
}
if ($request->session()->get('password_hash') !== $request->user()->getAuthPassword()) {
if ($request->session()->get('password_hash_'.$this->auth->getDefaultDriver()) !== $request->user()->getAuthPassword()) {
$this->logout($request);
}
return tap($next($request), function () use ($request) {
$this->storePasswordHashInSession($request);
if (! is_null($this->guard()->user())) {
$this->storePasswordHashInSession($request);
}
});
}
@@ -73,7 +75,7 @@ class AuthenticateSession
}
$request->session()->put([
'password_hash' => $request->user()->getAuthPassword(),
'password_hash_'.$this->auth->getDefaultDriver() => $request->user()->getAuthPassword(),
]);
}
@@ -87,10 +89,20 @@ class AuthenticateSession
*/
protected function logout($request)
{
$this->auth->logoutCurrentDevice();
$this->guard()->logoutCurrentDevice();
$request->session()->flush();
throw new AuthenticationException;
throw new AuthenticationException('Unauthenticated.', [$this->auth->getDefaultDriver()]);
}
/**
* Get the guard instance that should be used by the middleware.
*
* @return \Illuminate\Contracts\Auth\Factory|\Illuminate\Contracts\Auth\Guard
*/
protected function guard()
{
return $this->auth;
}
}

View File

@@ -5,6 +5,7 @@ namespace Illuminate\Session\Middleware;
use Closure;
use Illuminate\Contracts\Session\Session;
use Illuminate\Http\Request;
use Illuminate\Routing\Route;
use Illuminate\Session\SessionManager;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Date;
@@ -56,11 +57,11 @@ class StartSession
$session = $this->getSession($request);
if ($this->manager->shouldBlock() ||
($request->route() && $request->route()->locksFor())) {
($request->route() instanceof Route && $request->route()->locksFor())) {
return $this->handleRequestWhileBlocking($request, $session, $next);
} else {
return $this->handleStatefulRequest($request, $session, $next);
}
return $this->handleStatefulRequest($request, $session, $next);
}
/**
@@ -73,6 +74,10 @@ class StartSession
*/
protected function handleRequestWhileBlocking(Request $request, $session, Closure $next)
{
if (! $request->route() instanceof Route) {
return;
}
$lockFor = $request->route() && $request->route()->locksFor()
? $request->route()->locksFor()
: 10;
@@ -195,7 +200,7 @@ class StartSession
protected function storeCurrentUrl(Request $request, $session)
{
if ($request->method() === 'GET' &&
$request->route() &&
$request->route() instanceof Route &&
! $request->ajax() &&
! $request->prefetch()) {
$session->setPreviousUrl($request->fullUrl());

View File

@@ -8,7 +8,10 @@ class NullSessionHandler implements SessionHandlerInterface
{
/**
* {@inheritdoc}
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function open($savePath, $sessionName)
{
return true;
@@ -16,7 +19,10 @@ class NullSessionHandler implements SessionHandlerInterface
/**
* {@inheritdoc}
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function close()
{
return true;
@@ -24,7 +30,10 @@ class NullSessionHandler implements SessionHandlerInterface
/**
* {@inheritdoc}
*
* @return string|false
*/
#[\ReturnTypeWillChange]
public function read($sessionId)
{
return '';
@@ -32,7 +41,10 @@ class NullSessionHandler implements SessionHandlerInterface
/**
* {@inheritdoc}
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function write($sessionId, $data)
{
return true;
@@ -40,7 +52,10 @@ class NullSessionHandler implements SessionHandlerInterface
/**
* {@inheritdoc}
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function destroy($sessionId)
{
return true;
@@ -48,7 +63,10 @@ class NullSessionHandler implements SessionHandlerInterface
/**
* {@inheritdoc}
*
* @return int|false
*/
#[\ReturnTypeWillChange]
public function gc($lifetime)
{
return true;

0
vendor/laravel/framework/src/Illuminate/Session/SessionManager.php vendored Normal file → Executable file
View File

View File

@@ -19,9 +19,9 @@ class SessionServiceProvider extends ServiceProvider
$this->registerSessionDriver();
$this->app->singleton(StartSession::class, function () {
return new StartSession($this->app->make(SessionManager::class), function () {
return $this->app->make(CacheFactory::class);
$this->app->singleton(StartSession::class, function ($app) {
return new StartSession($app->make(SessionManager::class), function () use ($app) {
return $app->make(CacheFactory::class);
});
});
}

21
vendor/laravel/framework/src/Illuminate/Session/Store.php vendored Normal file → Executable file
View File

@@ -193,6 +193,17 @@ class Store implements Session
});
}
/**
* Determine if the given key is missing from the session data.
*
* @param string|array $key
* @return bool
*/
public function missing($key)
{
return ! $this->exists($key);
}
/**
* Checks if a key is present and not null.
*
@@ -637,6 +648,16 @@ class Store implements Session
$this->put('_previous.url', $url);
}
/**
* Specify that the user has confirmed their password.
*
* @return void
*/
public function passwordConfirmed()
{
$this->put('auth.password_confirmed_at', time());
}
/**
* Get the underlying session handler implementation.
*

View File

17
vendor/laravel/framework/src/Illuminate/Session/composer.json vendored Normal file → Executable file
View File

@@ -14,13 +14,14 @@
}
],
"require": {
"php": "^7.2.5|^8.0",
"php": "^7.3|^8.0",
"ext-json": "*",
"illuminate/contracts": "^7.0",
"illuminate/filesystem": "^7.0",
"illuminate/support": "^7.0",
"symfony/finder": "^5.0",
"symfony/http-foundation": "^5.0"
"illuminate/collections": "^8.0",
"illuminate/contracts": "^8.0",
"illuminate/filesystem": "^8.0",
"illuminate/support": "^8.0",
"symfony/finder": "^5.4",
"symfony/http-foundation": "^5.4"
},
"autoload": {
"psr-4": {
@@ -29,11 +30,11 @@
},
"extra": {
"branch-alias": {
"dev-master": "7.x-dev"
"dev-master": "8.x-dev"
}
},
"suggest": {
"illuminate/console": "Required to use the session:table command (^7.0)."
"illuminate/console": "Required to use the session:table command (^8.0)."
},
"config": {
"sort-packages": true