Start of a debug screen

This commit is contained in:
Deon George 2023-01-27 19:59:31 +11:00
parent 58e171aea1
commit e0185345c8
8 changed files with 104 additions and 16 deletions

View File

@ -2,11 +2,12 @@
namespace App\Http\Controllers\Auth; namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\AuthenticatesUsers; use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
class LoginController extends Controller class LoginController extends Controller
{ {
/* /*

View File

@ -8,13 +8,23 @@ use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Crypt; use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\File;
use LdapRecord\Models\ModelNotFoundException;
use App\Ldap\Entry; use App\Ldap\Entry;
use App\Classes\LDAP\Server; use App\Classes\LDAP\Server;
use LdapRecord\Models\ModelNotFoundException;
class HomeController extends Controller class HomeController extends Controller
{ {
/**
* Debug Page
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function debug()
{
return view('debug');
}
/** /**
* Application home page * Application home page
*/ */

View File

@ -5,8 +5,7 @@ namespace App\Ldap;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use LdapRecord\Models\Model; use LdapRecord\Models\Model;
use LdapRecord\Models\ModelNotFoundException; use LdapRecord\Query\ObjectNotFoundException;
use LdapRecord\Query\Model\Builder;
use App\Classes\LDAP\Attribute\Factory; use App\Classes\LDAP\Attribute\Factory;
@ -19,16 +18,30 @@ class Entry extends Model
*/ */
public static $objectClasses = []; public static $objectClasses = [];
/* OVERRIDES */
public function getAttributes(): array
{
$result = collect();
foreach (parent::getAttributes() as $attribute => $value) {
$result->put($attribute,Factory::create($attribute,$value));
}
return $result->toArray();
}
/* STATIC METHODS */
/** /**
* Gets the root DN of the specified LDAPServer, or throws an exception if it * Gets the root DN of the specified LDAPServer, or throws an exception if it
* can't find it. * can't find it.
* *
* @param null $connection * @param null $connection
* @return Collection * @return Collection
* @throws ModelNotFoundException * @throws ObjectNotFoundException
* @testedin GetBaseDNTest::testBaseDNExists(); * @testedin GetBaseDNTest::testBaseDNExists();
*/ */
public function baseDN($connection = NULL): ?Collection public static function baseDN($connection = NULL): ?Collection
{ {
$base = static::on($connection ?? (new static)->getConnectionName()) $base = static::on($connection ?? (new static)->getConnectionName())
->in(NULL) ->in(NULL)
@ -45,16 +58,21 @@ class Entry extends Model
return $result; return $result;
} }
public function getAttributes(): array /* ATTRIBUTES */
{
$result = collect();
foreach (parent::getAttributes() as $attribute => $value) {
$result->put($attribute,Factory::create($attribute,$value));
}
return $result->toArray(); /**
* Return a key to use for sorting
*
* @todo This should be the DN in reverse order
* @return string
*/
public function getSortKeyAttribute(): string
{
return $this->getDn();
} }
/* METHODS */
/** /**
* Return an icon for a DN based on objectClass * Return an icon for a DN based on objectClass
* *
@ -126,7 +144,7 @@ class Entry extends Model
* *
* @param null $connection * @param null $connection
* @return Entry|null * @return Entry|null
* @throws ModelNotFoundException * @throws ObjectNotFoundException
* @testedin TranslateOidTest::testRootDSE(); * @testedin TranslateOidTest::testRootDSE();
*/ */
public function rootDSE($connection = NULL): ?Entry public function rootDSE($connection = NULL): ?Entry

View File

@ -17,4 +17,11 @@ class User extends Model
public static $objectClasses = [ public static $objectClasses = [
'posixAccount', 'posixAccount',
]; ];
}
/* METHODS */
public function getDn(): string
{
return $this->exists ? parent::getDn() : 'Anonymous';
}
}

View File

@ -37,9 +37,16 @@
<div class="font-icon-wrapper float-left mr-1 server-icon"> <div class="font-icon-wrapper float-left mr-1 server-icon">
<a class="p-0 m-0" href="{{ LaravelLocalization::localizeUrl('info') }}" onclick="return false;" style="display: contents;"><i class="fas fa-fw fa-info pr-1 pl-1"></i></a> <a class="p-0 m-0" href="{{ LaravelLocalization::localizeUrl('info') }}" onclick="return false;" style="display: contents;"><i class="fas fa-fw fa-info pr-1 pl-1"></i></a>
</div> </div>
{{--
<div class="font-icon-wrapper float-left ml-1 mr-1 server-icon"> <div class="font-icon-wrapper float-left ml-1 mr-1 server-icon">
<a class="p-0 m-0" href="{{ LaravelLocalization::localizeUrl('schema') }}" onclick="return false;" style="display: contents;"><i class="fas fa-fw fa-fingerprint pr-1 pl-1"></i></a> <a class="p-0 m-0" href="{{ LaravelLocalization::localizeUrl('schema') }}" onclick="return false;" style="display: contents;"><i class="fas fa-fw fa-fingerprint pr-1 pl-1"></i></a>
</div> </div>
--}}
@env(['local'])
<div class="font-icon-wrapper float-right ml-1 mr-1 server-icon">
<a class="p-0 m-0" href="{{ LaravelLocalization::localizeUrl('debug') }}" onclick="return false;" style="display: contents;"><i class="fas fa-fw fa-toolbox pr-1 pl-1"></i></a>
</div>
@endenv
<div class="clearfix"></div> <div class="clearfix"></div>
</li> </li>
<li> <li>

View File

@ -51,6 +51,10 @@
</div> </div>
<div class="app-header-right"> <div class="app-header-right">
@if(! request()->isSecure())
<span class="badge badge-danger">WARNING - SESSION NOT SECURE</span>
@endif
<div class="header-btn-lg pr-0"> <div class="header-btn-lg pr-0">
<div class="widget-content p-0"> <div class="widget-content p-0">
<div class="widget-content-wrapper"> <div class="widget-content-wrapper">

View File

@ -0,0 +1,40 @@
<div class="card card-solid">
<div class="card-body">
<div class="row">
<div class="col-12">
<h3 class="d-inline-block">DEBUG Information</h3>
<table class="table">
<thead>
<tr>
<th>Setting</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<!-- User Logged In -->
<tr>
<td>User</td>
<td>{{ $user }}</td>
</tr>
<!-- Base DNs -->
<tr>
<td>BaseDN(s)</td>
<td>
<table class="table table-sm table-borderless">
@foreach(\App\Ldap\Entry::baseDN()->sort(function($item) { return $item->sortKey; }) as $item)
<tr>
<td>{{ $item->getDn() }}</td>
</tr>
@endforeach
</table>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>

View File

@ -29,6 +29,7 @@ Route::group(['prefix' => LaravelLocalization::setLocale()], function() {
Route::get('/',[HomeController::class,'home']); Route::get('/',[HomeController::class,'home']);
Route::get('info',[HomeController::class,'info']); Route::get('info',[HomeController::class,'info']);
Route::post('dn',[HomeController::class,'dn_frame']); Route::post('dn',[HomeController::class,'dn_frame']);
Route::get('debug',[HomeController::class,'debug']);
}); });
Route::get('logout',[LoginController::class,'logout']); Route::get('logout',[LoginController::class,'logout']);