Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel auth service #2823

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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