Skip to content

Commit

Permalink
Merge pull request #2823 from Leantime/laravelAuthService
Browse files Browse the repository at this point in the history
Laravel auth service
  • Loading branch information
marcelfolaron authored Nov 26, 2024
2 parents d998a83 + 936dcbf commit 1cbd74c
Show file tree
Hide file tree
Showing 27 changed files with 562 additions and 424 deletions.
32 changes: 0 additions & 32 deletions .idea/leantime-oss.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 0 additions & 32 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 12 additions & 9 deletions app/Command/CheckTranslations.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use Illuminate\Console\Command;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Finder\Finder;

#[AsCommand(
name: 'translations:check-unused',
Expand All @@ -21,6 +21,7 @@ class CheckTranslations extends Command
protected $description = 'Scan codebase for unused translation strings';

protected $translations = [];

protected $usedTranslations = [];

public function handle()
Expand All @@ -42,8 +43,9 @@ public function handle()
private function parseLanguageFile(): void
{
$langFile = app_path('Language/en-US.ini');
if (!file_exists($langFile)) {
$this->error('Language file not found: ' . $langFile);
if (! file_exists($langFile)) {
$this->error('Language file not found: '.$langFile);

return;
}

Expand All @@ -60,10 +62,10 @@ private function scanFiles(): void
$excludeDirs = explode(',', $this->option('exclude'));

if ($this->option('debug')) {
$this->info('Excluding directories: ' . implode(', ', $excludeDirs));
$this->info('Excluding directories: '.implode(', ', $excludeDirs));
}

$finder = new Finder();
$finder = new Finder;
$finder->files()
->in(app_path())
->name('*.php')
Expand Down Expand Up @@ -97,18 +99,18 @@ private function scanFileForTranslations($file): void
preg_quote($key, '/'), // Direct key usage
preg_quote("'$key'", '/'), // Single quoted
preg_quote("\"$key\"", '/'), // Double quoted
preg_quote('__("' . $key . '")', '/'), // PHP translation function
preg_quote('__("'.$key.'")', '/'), // PHP translation function
preg_quote("__('$key')", '/'), // PHP translation function
preg_quote('$tpl->__("' . $key . '")', '/'), // Template translation
preg_quote('$tpl->__(\'' . $key . '\')', '/'), // Template translation
preg_quote('$tpl->__("'.$key.'")', '/'), // Template translation
preg_quote('$tpl->__(\''.$key.'\')', '/'), // Template translation
];

if ($this->option('debug')) {
$this->line("Scanning file: {$filePath}");
}

foreach ($patterns as $pattern) {
if (preg_match('/' . $pattern . '/', $content)) {
if (preg_match('/'.$pattern.'/', $content)) {
if ($this->option('debug')) {
$this->line(" - Found usage of key: {$key}");
}
Expand All @@ -125,6 +127,7 @@ private function generateReport(): void

if (empty($unusedTranslations)) {
$this->info('No unused translations found.');

return;
}

Expand Down
41 changes: 37 additions & 4 deletions app/Core/Configuration/laravelConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
\Illuminate\Validation\ValidationServiceProvider::class,
//\Illuminate\View\ViewServiceProvider::class,

\Leantime\Core\Providers\Auth::class,
\Leantime\Core\Providers\Authentication::class,
\Leantime\Core\Providers\RateLimiter::class,
\Leantime\Core\Providers\Db::class,
\Leantime\Core\Providers\Language::class,
Expand Down Expand Up @@ -94,7 +94,8 @@
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => ['single'],
// Add the Sentry log channel to the stack
'channels' => ['single', 'sentry'],
],
'single' => [
'driver' => 'daily',
Expand All @@ -114,6 +115,11 @@
'level' => 'critical',
'replace_placeholders' => true,
],
'sentry' => [
'driver' => 'sentry',
'level' => 'error',
'bubble' => true,
],
],
'default' => 'stack',
],
Expand All @@ -129,6 +135,7 @@
| specified when running a cache operation inside the application.
|
*/

'default' => 'installation',

/*
Expand Down Expand Up @@ -205,7 +212,7 @@
|
*/

'lifetime' => 480, //8 hours
'lifetime' => env('LEAN_SESSION_EXPIRATION', 480), //8 hours

'expire_on_close' => false,

Expand Down Expand Up @@ -389,6 +396,7 @@
'compiled' => realpath(storage_path('framework/views')),

],

'database' => [
'default' => env('LEAN_DB_DEFAULT_CONNECTION', 'mysql'),
/*
Expand Down Expand Up @@ -439,7 +447,6 @@
],

],

/*
|--------------------------------------------------------------------------
| Redis Databases
Expand All @@ -453,9 +460,11 @@
'redis' => [
'client' => 'phpredis',
'options' => [
'parameters' => ['timeout' => 1.0],
'cluster' => 'redis',
'context' => [],
'compression' => 3, // Redis::COMPRESSION_LZ4
'password' => '',
],
'default' => [
'url' => env('LEAN_REDIS_URL', ''),
Expand All @@ -464,7 +473,31 @@
'password' => env('LEAN_REDIS_PASSWORD', null),
'port' => env('LEAN_REDIS_PORT', '127.0.0.1'),
'database' => '0',
'read_timeout' => 1.0,
'prefix' => 'leantime_cache',
],
],

// Driver options: eloquent, database (using db query builder),
'auth' => [
'defaults' => [
'guard' => 'leantime',
'passwords' => 'users',
],
'guards' => [
'leantime' => [
'driver' => 'leantime',
'provider' => 'leantimeUsers',
],
'jsonRpc' => [
'driver' => 'jsonRpc',
'provider' => 'leantimeUsers',
],
],
'providers' => [
'leantimeUsers' => [
'driver' => 'leantimeUsers',
],
],
],
];
58 changes: 0 additions & 58 deletions app/Core/Contracts/Service.php

This file was deleted.

14 changes: 8 additions & 6 deletions app/Core/Http/HttpKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class HttpKernel extends Kernel
\Leantime\Core\Middleware\StartSession::class,
\Leantime\Core\Middleware\Installed::class,
\Leantime\Core\Middleware\Updated::class,
\Leantime\Core\Middleware\AuthCheck::class,

\Leantime\Core\Middleware\RequestRateLimiter::class,
\Illuminate\Http\Middleware\HandleCors::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
Expand All @@ -53,14 +55,14 @@ class HttpKernel extends Kernel
*/
protected $middlewareGroups = [
'web' => [
\Leantime\Core\Middleware\Auth::class,

\Leantime\Core\Middleware\CurrentProject::class,
],
'api' => [
\Leantime\Core\Middleware\ApiAuth::class,
\Leantime\Core\Middleware\AuthCheck::class,
],
'hx' => [
\Leantime\Core\Middleware\Auth::class,
\Leantime\Core\Middleware\AuthCheck::class,
\Leantime\Core\Middleware\CurrentProject::class,
],
];
Expand All @@ -73,7 +75,7 @@ class HttpKernel extends Kernel
* @var array<string, class-string|string>
*/
protected $middlewareAliases = [
//'auth' => \App\Http\Middleware\Authenticate::class,
'auth' => \Leantime\Core\Middleware\AuthCheck::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
Expand All @@ -100,10 +102,10 @@ protected function sendRequestThroughRouter($request)

if ($request instanceof ApiRequest) {

array_splice($this->middleware, 5, 0, $this->middlewareGroups['api']);
array_splice($this->middleware, 6, 0, $this->middlewareGroups['api']);

} else {
array_splice($this->middleware, 5, 0, $this->middlewareGroups['web']);
array_splice($this->middleware, 6, 0, $this->middlewareGroups['web']);
}

//This filter only works for system plugins
Expand Down
Loading

0 comments on commit 1cbd74c

Please sign in to comment.