diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 7a19223..3f0ae8f 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -2,11 +2,12 @@ namespace App\Http\Controllers\Auth; -use App\Http\Controllers\Controller; -use App\Providers\RouteServiceProvider; use Illuminate\Foundation\Auth\AuthenticatesUsers; use Illuminate\Http\Request; +use App\Http\Controllers\Controller; +use App\Providers\RouteServiceProvider; + class LoginController extends Controller { /* diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index ad53005..5af3d11 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -8,13 +8,23 @@ use Illuminate\Support\Collection; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Crypt; use Illuminate\Support\Facades\File; +use LdapRecord\Models\ModelNotFoundException; use App\Ldap\Entry; use App\Classes\LDAP\Server; -use LdapRecord\Models\ModelNotFoundException; 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 */ diff --git a/app/Ldap/Entry.php b/app/Ldap/Entry.php index 7f57794..9b60322 100644 --- a/app/Ldap/Entry.php +++ b/app/Ldap/Entry.php @@ -5,8 +5,7 @@ namespace App\Ldap; use Illuminate\Support\Arr; use Illuminate\Support\Collection; use LdapRecord\Models\Model; -use LdapRecord\Models\ModelNotFoundException; -use LdapRecord\Query\Model\Builder; +use LdapRecord\Query\ObjectNotFoundException; use App\Classes\LDAP\Attribute\Factory; @@ -19,16 +18,30 @@ class Entry extends Model */ 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 * can't find it. * * @param null $connection * @return Collection - * @throws ModelNotFoundException + * @throws ObjectNotFoundException * @testedin GetBaseDNTest::testBaseDNExists(); */ - public function baseDN($connection = NULL): ?Collection + public static function baseDN($connection = NULL): ?Collection { $base = static::on($connection ?? (new static)->getConnectionName()) ->in(NULL) @@ -45,16 +58,21 @@ class Entry extends Model return $result; } - public function getAttributes(): array - { - $result = collect(); - foreach (parent::getAttributes() as $attribute => $value) { - $result->put($attribute,Factory::create($attribute,$value)); - } + /* ATTRIBUTES */ - 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 * @@ -126,7 +144,7 @@ class Entry extends Model * * @param null $connection * @return Entry|null - * @throws ModelNotFoundException + * @throws ObjectNotFoundException * @testedin TranslateOidTest::testRootDSE(); */ public function rootDSE($connection = NULL): ?Entry diff --git a/app/Ldap/User.php b/app/Ldap/User.php index 733535a..69b1729 100644 --- a/app/Ldap/User.php +++ b/app/Ldap/User.php @@ -17,4 +17,11 @@ class User extends Model public static $objectClasses = [ 'posixAccount', ]; -} + + /* METHODS */ + + public function getDn(): string + { + return $this->exists ? parent::getDn() : 'Anonymous'; + } +} \ No newline at end of file diff --git a/resources/themes/architect/views/layouts/partials/sidebarmenu.blade.php b/resources/themes/architect/views/layouts/partials/sidebarmenu.blade.php index 796bd3e..f545130 100644 --- a/resources/themes/architect/views/layouts/partials/sidebarmenu.blade.php +++ b/resources/themes/architect/views/layouts/partials/sidebarmenu.blade.php @@ -37,9 +37,16 @@
+ {{--
+ --}} + @env(['local']) +
+ +
+ @endenv
  • diff --git a/resources/themes/architect/views/layouts/partials/topmenu.blade.php b/resources/themes/architect/views/layouts/partials/topmenu.blade.php index 1342655..e563247 100644 --- a/resources/themes/architect/views/layouts/partials/topmenu.blade.php +++ b/resources/themes/architect/views/layouts/partials/topmenu.blade.php @@ -51,6 +51,10 @@
    + @if(! request()->isSecure()) + WARNING - SESSION NOT SECURE + @endif +
    diff --git a/resources/views/debug.blade.php b/resources/views/debug.blade.php new file mode 100644 index 0000000..e3ac732 --- /dev/null +++ b/resources/views/debug.blade.php @@ -0,0 +1,40 @@ +
    +
    +
    +
    +

    DEBUG Information

    + + + + + + + + + + + + + + + + + + + + + + +
    SettingValue
    User{{ $user }}
    BaseDN(s) + + @foreach(\App\Ldap\Entry::baseDN()->sort(function($item) { return $item->sortKey; }) as $item) + + + + @endforeach +
    {{ $item->getDn() }}
    +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index fbe0d6b..8508c34 100644 --- a/routes/web.php +++ b/routes/web.php @@ -29,6 +29,7 @@ Route::group(['prefix' => LaravelLocalization::setLocale()], function() { Route::get('/',[HomeController::class,'home']); Route::get('info',[HomeController::class,'info']); Route::post('dn',[HomeController::class,'dn_frame']); + Route::get('debug',[HomeController::class,'debug']); }); Route::get('logout',[LoginController::class,'logout']);