mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
* Rewrite user management. Error management Revert edituser legacy page Connect user permissions button to legacy page for now. Implement user creation Refine form Remove PingCheck.php accidental add :) Fixes for redirection and deletion More fixes: realname accidental validation setting, hide can modify for read-only auths Use a panel to improve style Add icon to panel-title Not allowed to delete own user (at least via the click of a button) Use request validation to reduce complexity of controller. Improve protection against users doing things they should not. Switch to horizontal form and not nearly as wide of layout :) delete without refresh. Fix for buttons Include all users (not just from this auth) Hide the auth column if there is only one auth type Show username if real name isn't set Don't allow creation of demo users via the webui a fix to the lnms user:add command, it didn't set auth_id update edituser.inc.php to current just redirect to users page * Remove TwoFactorTest for now * Update edituser.inc.php * Update .env.dusk.testing * Enable 2fa for 2fa test...
60 lines
1.6 KiB
PHP
60 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Models\User;
|
|
use App\Policies\UserPolicy;
|
|
use App\Guards\ApiTokenGuard;
|
|
use Auth;
|
|
use Illuminate\Support\Facades\Gate;
|
|
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
|
|
|
class AuthServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* The policy mappings for the application.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $policies = [
|
|
User::class => UserPolicy::class
|
|
];
|
|
|
|
/**
|
|
* Register any authentication / authorization services.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function boot()
|
|
{
|
|
$this->registerPolicies();
|
|
|
|
Auth::provider('legacy', function ($app, array $config) {
|
|
return new LegacyUserProvider();
|
|
});
|
|
|
|
Auth::provider('token_provider', function ($app, array $config) {
|
|
return new TokenUserProvider();
|
|
});
|
|
|
|
Auth::extend('token_driver', function ($app, $name, array $config) {
|
|
$userProvider = $app->make(TokenUserProvider::class);
|
|
$request = $app->make('request');
|
|
return new ApiTokenGuard($userProvider, $request);
|
|
});
|
|
|
|
Gate::define('global-admin', function ($user) {
|
|
return $user->hasGlobalAdmin();
|
|
});
|
|
Gate::define('admin', function ($user) {
|
|
return $user->isAdmin();
|
|
});
|
|
Gate::define('global-read', function ($user) {
|
|
return $user->hasGlobalRead();
|
|
});
|
|
Gate::define('device', function ($user, $device) {
|
|
return $user->canAccessDevice($device);
|
|
});
|
|
}
|
|
}
|