├── .env.example
├── .gitattributes
├── .gitignore
├── app
├── Console
│ ├── Commands
│ │ ├── CopacoSetupDev.php
│ │ └── DeployAdminlteAssets.php
│ └── Kernel.php
├── Exceptions
│ └── Handler.php
├── Exports
│ └── ExcelExport.php
├── Http
│ ├── Controllers
│ │ ├── Api
│ │ │ ├── DhcpController.php
│ │ │ └── FreeradiusController.php
│ │ ├── Auth
│ │ │ ├── LoginController.php
│ │ │ └── RegisterController.php
│ │ ├── ConfigController.php
│ │ ├── Controller.php
│ │ ├── EquipamentoController.php
│ │ ├── FileController.php
│ │ ├── FreeradiusController.php
│ │ ├── IndexController.php
│ │ ├── RedeController.php
│ │ ├── RoleController.php
│ │ └── UserController.php
│ ├── Kernel.php
│ ├── Middleware
│ │ ├── EncryptCookies.php
│ │ ├── RedirectIfAuthenticated.php
│ │ ├── TrimStrings.php
│ │ ├── TrustProxies.php
│ │ └── VerifyCsrfToken.php
│ └── Requests
│ │ ├── EquipamentoRequest.php
│ │ └── RedeRequest.php
├── Models
│ ├── Config.php
│ ├── Equipamento.php
│ ├── File.php
│ ├── Rede.php
│ ├── Role.php
│ └── User.php
├── Observers
│ ├── EquipamentoObserver.php
│ └── RedeObserver.php
├── Policies
│ └── EquipamentoPolicy.php
├── Providers
│ ├── AppServiceProvider.php
│ ├── AuthServiceProvider.php
│ ├── BroadcastServiceProvider.php
│ ├── EventServiceProvider.php
│ └── RouteServiceProvider.php
├── Rules
│ ├── CodigoAcesso.php
│ ├── Domain.php
│ ├── MacAddress.php
│ ├── MultiplesIP.php
│ ├── Patrimonio.php
│ ├── PertenceRede.php
│ └── RedeCidr.php
└── Utils
│ ├── Freeradius.php
│ ├── NetworkOps.php
│ └── Utils.php
├── artisan
├── bootstrap
├── app.php
└── cache
│ └── .gitignore
├── composer.json
├── composer.lock
├── config
├── app.php
├── audit.php
├── auth.php
├── broadcasting.php
├── cache.php
├── copaco.php
├── database.php
├── excel.php
├── filesystems.php
├── laravel-usp-theme-sistemas.php
├── laravel-usp-theme.php
├── logging.php
├── mail.php
├── queue.php
├── senhaunica.php
├── services.php
├── session.php
└── view.php
├── database
├── .gitignore
├── factories
│ ├── EquipamentoFactory.php
│ ├── FileFactory.php
│ ├── RedeFactory.php
│ ├── RoleFactory.php
│ └── UserFactory.php
├── migrations
│ ├── 2014_10_12_000000_create_users_table.php
│ ├── 2014_10_12_100000_create_password_resets_table.php
│ ├── 2018_01_23_173421_create_redes_table.php
│ ├── 2018_01_23_180822_create_equipamentos_table.php
│ ├── 2018_09_25_161702_create_roles_table.php
│ ├── 2018_09_25_161829_create_role_user_table.php
│ ├── 2018_09_25_202335_create_role_rede_table.php
│ ├── 2018_10_03_174951_nullable_fields_rede.php
│ ├── 2018_10_04_141540_create_configs_table.php
│ ├── 2019_04_08_155236_rename_username_senhaunica_column.php
│ ├── 2019_05_29_222847_remove_last_modify_by_from_redes.php
│ ├── 2019_05_29_224725_create_redes_changes.php
│ ├── 2019_05_30_145753_create_equipamentos_changes.php
│ ├── 2019_10_27_185832_add_unknown_clients.php
│ ├── 2019_10_31_122019_drop_unknown_clients.php
│ ├── 2019_10_31_122118_add_dhcpd_subnet_options.php
│ ├── 2019_11_01_014221_add_shared.php
│ ├── 2020_11_17_181030_change_columns_in_equipamentos.php
│ ├── 2021_02_25_020004_new_columns_redes_table.php
│ ├── 2021_03_25_215743_change_column_descricao_equipamentos_table.php
│ ├── 2021_04_01_033039_create_audits_table.php
│ ├── 2021_04_01_041328_drop_equipamentos_changes_table.php
│ ├── 2021_04_01_184053_drop_redes_changes_table.php
│ └── 2021_04_05_152721_create_files_table.php
└── seeders
│ ├── ConfigsTableSeeder.php
│ ├── DatabaseSeeder.php
│ ├── EquipamentosTableSeeder.php
│ ├── FileSeeder.php
│ ├── RedesTableSeeder.php
│ ├── RolesTableSeeder.php
│ └── UsersTableSeeder.php
├── package.json
├── phpunit.xml
├── public
├── .htaccess
├── assets
│ ├── css
│ │ └── copaco.css
│ └── js
│ │ └── copaco.js
├── favicon.ico
├── index.php
├── robots.txt
└── web.config
├── readme.md
├── resources
├── assets
│ ├── js
│ │ ├── bootstrap.js
│ │ └── components
│ │ │ └── ExampleComponent.vue
│ └── sass
│ │ ├── _variables.scss
│ │ ├── app.scss
│ │ └── dashboard.scss
├── lang
│ ├── en
│ │ ├── auth.php
│ │ ├── pagination.php
│ │ ├── passwords.php
│ │ └── validation.php
│ └── pt-br
│ │ └── validation.php
└── views
│ ├── auth
│ ├── login.blade.php
│ ├── passwords
│ │ ├── email.blade.php
│ │ └── reset.blade.php
│ └── register.blade.php
│ ├── config
│ ├── index.blade.php
│ └── partials
│ │ ├── dhcp.blade.php
│ │ └── dhcp_sem_subnets.blade.php
│ ├── equipamentos
│ ├── create.blade.php
│ ├── edit.blade.php
│ ├── files
│ │ └── partials
│ │ │ └── form.blade.php
│ ├── form.blade.php
│ ├── index.blade.php
│ ├── partials
│ │ └── files.blade.php
│ └── show.blade.php
│ ├── index.blade.php
│ ├── master.blade.php
│ ├── messages
│ ├── errors.blade.php
│ └── flash.blade.php
│ ├── partials
│ └── audit
│ │ └── index.blade.php
│ ├── redes
│ ├── create.blade.php
│ ├── edit.blade.php
│ ├── form.blade.php
│ ├── index.blade.php
│ ├── migrate.blade.php
│ └── show.blade.php
│ ├── roles
│ ├── create.blade.php
│ ├── edit.blade.php
│ ├── form.blade.php
│ ├── index.blade.php
│ └── show.blade.php
│ ├── users
│ ├── edit.blade.php
│ ├── form.blade.php
│ ├── index.blade.php
│ └── show.blade.php
│ └── vendor
│ └── adminlte
│ └── page.blade.php
├── routes
├── api.php
├── channels.php
├── console.php
└── web.php
├── server.php
├── storage
├── app
│ ├── .gitignore
│ └── public
│ │ └── .gitignore
├── framework
│ ├── .gitignore
│ ├── cache
│ │ └── .gitignore
│ ├── sessions
│ │ └── .gitignore
│ ├── testing
│ │ └── .gitignore
│ └── views
│ │ └── .gitignore
└── logs
│ └── .gitignore
├── tests
├── CreatesApplication.php
├── NetworkOps_test.php
├── TestCase.php
└── ip_example
└── webpack.mix.js
/.env.example:
--------------------------------------------------------------------------------
1 | APP_NAME=Copaco
2 | APP_ENV=local
3 | APP_KEY=
4 | APP_DEBUG=true
5 | APP_URL=http://localhost
6 |
7 | DB_CONNECTION=mysql
8 | DB_HOST=127.0.0.1
9 | DB_PORT=3306
10 | DB_DATABASE=homestead
11 | DB_USERNAME=root
12 | DB_PASSWORD=
13 |
14 | BROADCAST_DRIVER=log
15 | CACHE_DRIVER=file
16 | SESSION_DRIVER=file
17 | SESSION_LIFETIME=120
18 | QUEUE_DRIVER=sync
19 |
20 | REDIS_HOST=127.0.0.1
21 | REDIS_PASSWORD=null
22 | REDIS_PORT=6379
23 |
24 | MAIL_DRIVER=smtp
25 | MAIL_HOST=smtp.mailtrap.io
26 | MAIL_PORT=2525
27 | MAIL_USERNAME=null
28 | MAIL_PASSWORD=null
29 | MAIL_ENCRYPTION=null
30 |
31 | PUSHER_APP_ID=
32 | PUSHER_APP_KEY=
33 | PUSHER_APP_SECRET=
34 | PUSHER_APP_CLUSTER=mt1
35 |
36 | SENHAUNICA_KEY=
37 | SENHAUNICA_SECRET=
38 | SENHAUNICA_CALLBACK_ID=
39 | SENHAUNICA_DEV="https://dev.uspdigital.usp.br/wsusuario/oauth"
40 |
41 | SENHAUNICA_UNIDADES=FFLCH,ECA,IME
42 |
43 | SUPERADMINS_USERNAMES=admin,5385361
44 |
45 | CONSUMER_DEPLOY_KEY=d3f23321004dhd892nfAzt1OMC0xAAyoaeQ
46 |
47 | FREERADIUS_HABILITAR=False
48 | FREERADIUS_HOST=localhost
49 | FREERADIUS_USER=freeradius
50 | FREERADIUS_DB=freeradius
51 | FREERADIUS_PASSWD=freeradius
52 | FREERADIUS_MACADDR_SEPARATOR='-'
53 | FREERADIUS_MACADDR_CASE=lower
54 |
55 | CODIGO_ACESSO='ABCD-1234'
56 | SOMENTE_SENHAUNICA=false
57 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 | *.css linguist-vendored
3 | *.scss linguist-vendored
4 | *.js linguist-vendored
5 | CHANGELOG.md export-ignore
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
2 | /public/hot
3 | /public/fonts
4 | /public/css
5 | /public/js
6 | /public/mix-manifest.json
7 | /public/storage
8 | /storage/*.key
9 | /vendor
10 | /.idea
11 | /.vagrant
12 | /.phpintel/
13 | Homestead.json
14 | Homestead.yaml
15 | npm-debug.log
16 | yarn-error.log
17 | .env
18 | *.swp
19 | *~
20 | package-lock.json
21 | tags
22 | public/vendor/
23 |
24 | # Assets do AdminLTE
25 |
26 | /public/vendor/adminlte
27 | !public/assets
28 | .phpunit.result.cache
29 |
--------------------------------------------------------------------------------
/app/Console/Commands/CopacoSetupDev.php:
--------------------------------------------------------------------------------
1 | error($erro);
43 | exit(1);
44 | }
45 | $this->info("Gerando usuário para dev...");
46 | // Chamando o seeder
47 | $this->call('db:seed', [
48 | '--class' => 'DevUserSeeder'
49 | ]);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/app/Console/Commands/DeployAdminlteAssets.php:
--------------------------------------------------------------------------------
1 | info("Deploying Assets...");
41 |
42 | // Calling the service provider
43 | $this->call('vendor:publish', [
44 | '--provider' => 'Uspdev\UspTheme\ServiceProvider',
45 | '--tag' => 'assets'
46 | ]);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/app/Console/Kernel.php:
--------------------------------------------------------------------------------
1 | command('inspire')
28 | // ->hourly();
29 | }
30 |
31 | /**
32 | * Register the commands for the application.
33 | *
34 | * @return void
35 | */
36 | protected function commands()
37 | {
38 | $this->load(__DIR__.'/Commands');
39 |
40 | require base_path('routes/console.php');
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/app/Exceptions/Handler.php:
--------------------------------------------------------------------------------
1 | data = $data;
15 | $this->headings = $headings;
16 | }
17 |
18 | public function array() : array
19 | {
20 | return $this->data;
21 | }
22 |
23 | public function headings(): array
24 | {
25 | return $this->headings;
26 | }
27 | }
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/FreeradiusController.php:
--------------------------------------------------------------------------------
1 | consumer_deploy_key != config('copaco.consumer_deploy_key')) {
27 | return response('Unauthorized action.', 403);
28 | }
29 | $freeradius = new Freeradius;
30 | $file = $freeradius->file();
31 | return response($file)->header('Content-Type', 'text/plain');
32 | }
33 | }
--------------------------------------------------------------------------------
/app/Http/Controllers/Auth/LoginController.php:
--------------------------------------------------------------------------------
1 | middleware('guest')->except('logout');
42 | }
43 |
44 | public function username()
45 | {
46 | return 'username';
47 | }
48 |
49 | public function redirectToProvider()
50 | {
51 | return Socialite::driver('senhaunica')->redirect();
52 | }
53 |
54 | public function handleProviderCallback(Request $request)
55 | {
56 | $userSenhaUnica = Socialite::driver('senhaunica')->user();
57 |
58 | # busca o usuário local
59 | $user = User::where('username',$userSenhaUnica->codpes)->first();
60 |
61 | if (is_null($user)) {
62 | $user = new User;
63 | }
64 |
65 | // precisamos saber se o usuário é autorizado
66 | $unidades = explode(',', trim(config('copaco.senha_unica_unidades')));
67 |
68 | if ($unidades) {
69 | if(config('copaco.allow_login_all')){
70 | $login = true;
71 | } else {
72 | $login = false;
73 | foreach ($userSenhaUnica->vinculo as $vinculo) {
74 | if (in_array($vinculo['siglaUnidade'], $unidades)) {
75 | if ($vinculo['tipoVinculo'] != 'ALUNOGR') {
76 | $login = true;
77 | }
78 | }
79 | }
80 | }
81 |
82 | }
83 |
84 | if (!$login) {
85 | $request->session()->flash('alert-danger', 'Usuário sem acesso ao sistema.');
86 | return redirect('/');
87 | }
88 |
89 | // bind do dados retornados
90 | $user->username = $userSenhaUnica->codpes;
91 | $user->email = $userSenhaUnica->email;
92 | $user->name = $userSenhaUnica->nompes;
93 | $user->save();
94 |
95 | Auth::login($user, true);
96 | return redirect('/');
97 | }
98 |
99 | public function logout()
100 | {
101 | Auth::logout();
102 | return redirect('/');
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Auth/RegisterController.php:
--------------------------------------------------------------------------------
1 | middleware('guest');
42 | }
43 |
44 | /**
45 | * Get a validator for an incoming registration request.
46 | *
47 | * @param array $data
48 | * @return \Illuminate\Contracts\Validation\Validator
49 | */
50 | protected function validator(array $data)
51 | {
52 |
53 | return Validator::make($data, [
54 | 'name' => 'required|string|max:255',
55 | 'username' => 'required|alpha_num|max:255|unique:users',
56 | 'email' => 'required|string|email|max:255|unique:users',
57 | 'password' => 'required|string|min:6|confirmed',
58 | 'codigo_acesso' => ['required', new CodigoAcesso],
59 | ]);
60 | }
61 |
62 | /**
63 | * Create a new user instance after a valid registration.
64 | *
65 | * @param array $data
66 | * @return \App\User
67 | */
68 | protected function create(array $data)
69 | {
70 | return User::create([
71 | 'name' => $data['name'],
72 | 'email' => $data['email'],
73 | 'username' => $data['username'],
74 | 'password' => bcrypt($data['password']),
75 | ]);
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/app/Http/Controllers/ConfigController.php:
--------------------------------------------------------------------------------
1 | middleware('can:admin');
15 | }
16 |
17 | public function index()
18 | {
19 | $redes = Rede::all();
20 | $configs = Config::all();
21 | $consumer_deploy_key = config('copaco.consumer_deploy_key');
22 | return view('config/index',compact('consumer_deploy_key','configs','redes'));
23 | }
24 |
25 | public function config(Request $request)
26 | {
27 | $keys = ['dhcp_global','shared_network','unique_iprede','unique_gateway','unique_cidr','ips_reservados'];
28 |
29 | foreach($keys as $key) {
30 |
31 | if($key == 'unique_iprede' || $key == 'unique_gateway') {
32 | $request->validate([
33 | $key => ['ip'],
34 | ]);
35 | }
36 |
37 | if($key == 'unique_cidr') {
38 | $request->validate([
39 | $key => 'required|numeric|min:8|max:30',
40 | ]);
41 | }
42 |
43 | if($key == 'ips_reservados') {
44 | $request->validate([
45 | $key => [new MultiplesIP('DNS')],
46 | ]);
47 | }
48 |
49 | $config = Config::where('key',$key)->first();
50 | if(is_null($config)) $config = new Config;
51 | $config->key = $key;
52 | $config->value = $request->{$key};
53 | $config->save();
54 | }
55 |
56 | $request->session()->flash('alert-success', 'Configuração atualizada com sucesso!');
57 | return redirect("/config");
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Controller.php:
--------------------------------------------------------------------------------
1 | authorize('equipamentos.create');
14 | $request->validate([
15 | 'file' => 'required',
16 | 'equipamento_id' => 'required|integer|exists:equipamentos,id',
17 | ]);
18 | $file = new File;
19 | $file->equipamento_id = $request->equipamento_id;
20 | $file->original_name = $request->file('file')->getClientOriginalName();
21 | $file->mimetype = $request->file('file')->getClientMimeType();
22 | $file->path = $request->file('file')->store('.');
23 | $file->user_id = auth()->user()->id ;
24 | $file->save();
25 | return back();
26 | }
27 |
28 | public function show(File $file)
29 | {
30 | $this->authorize('equipamentos.view', $file->equipamento);
31 | return Storage::download($file->path, $file->original_name);
32 | }
33 |
34 | public function destroy(File $file)
35 | {
36 | $this->authorize('equipamentos.delete', $file->equipamento);
37 | Storage::delete($file->path);
38 | $file->delete();
39 | return back();
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/app/Http/Controllers/FreeradiusController.php:
--------------------------------------------------------------------------------
1 | middleware('can:admin');
26 | $this->freeradius = new Freeradius;
27 | }
28 |
29 | public function sincronize(Request $request)
30 | {
31 | if (!config('copaco.freeradius_habilitar')) {
32 | $request->session()->flash('alert-warning', 'Freeradius não habilitado, nenhuma ação feita!');
33 | return redirect("/config");
34 | }
35 |
36 | // Limpa as tabelas
37 | DB::connection('freeradius')->table('radusergroup')->delete();
38 | DB::connection('freeradius')->table('radgroupreply')->delete();
39 | DB::connection('freeradius')->table('radcheck')->delete();
40 |
41 | // Re-inseri tudo novamente
42 | $redes = Rede::where('active_freeradius',1)->get();
43 | foreach ($redes as $rede) {
44 | $this->freeradius->cadastraOuAtualizaRede($rede);
45 | foreach ($rede->equipamentos as $equipamento) {
46 | $this->freeradius->cadastraOuAtualizaEquipamento($equipamento);
47 | }
48 | }
49 | $request->session()->flash('alert-warning', 'Freeradius sincronizado com sucesso!');
50 | return redirect("/config");
51 | }
52 | }
53 |
54 |
--------------------------------------------------------------------------------
/app/Http/Controllers/IndexController.php:
--------------------------------------------------------------------------------
1 | middleware('auth')->except(['index']);
12 | }
13 |
14 | public function index()
15 | {
16 | return view('index');
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/app/Http/Controllers/RoleController.php:
--------------------------------------------------------------------------------
1 | middleware('can:admin');
25 | }
26 |
27 | public function index()
28 | {
29 | $roles = Role::paginate(20);
30 | return view('roles.index')->with('roles', $roles);
31 | }
32 |
33 | /**
34 | * Show the form for creating a new resource.
35 | *
36 | * @return \Illuminate\Http\Response
37 | */
38 | public function create()
39 | {
40 | $redes = Rede::all();
41 | return view('roles.create',compact('redes'));
42 | }
43 |
44 | /**
45 | * Store a newly created resource in storage.
46 | *
47 | * @param \Illuminate\Http\Request $request
48 | * @return \Illuminate\Http\Response
49 | */
50 | public function store(Request $request)
51 | {
52 | // Validações
53 | $request->validate([
54 | 'nome' => 'required|unique:roles',
55 | ]);
56 |
57 | // Persistência
58 | $role = new Role;
59 | $role->nome = $request->nome;
60 | if(!empty($request->grupoadmin)) $role->grupoadmin = true;
61 | $role->save();
62 |
63 | // redes
64 | if(!empty($request->redes)){
65 | $role->redes()->sync($request->redes);
66 | }
67 | else {
68 | $role->redes()->detach();
69 | }
70 |
71 | $request->session()->flash('alert-success', 'Grupo cadastrado com sucesso!');
72 | return redirect()->route('roles.index');
73 | }
74 |
75 | /**
76 | * Display the specified resource.
77 | *
78 | * @param \App\Role $role
79 | * @return \Illuminate\Http\Response
80 | */
81 | public function show(Role $role)
82 | {
83 | return view('roles.show', compact('role'));
84 | }
85 |
86 | /**
87 | * Show the form for editing the specified resource.
88 | *
89 | * @param \App\Role $role
90 | * @return \Illuminate\Http\Response
91 | */
92 | public function edit(Role $role)
93 | {
94 | $redes = Rede::all();
95 | return view('roles.edit', compact('role','redes'));
96 | }
97 |
98 | /**
99 | * Update the specified resource in storage.
100 | *
101 | * @param \Illuminate\Http\Request $request
102 | * @param \App\Role $role
103 | * @return \Illuminate\Http\Response
104 | */
105 | public function update(Request $request, Role $role)
106 | {
107 | // Validações
108 | $request->validate([
109 | 'nome' => 'required|unique:roles,nome,'. $role->id
110 |
111 | ]);
112 |
113 | // redes
114 | if(!empty($request->redes)){
115 | $role->redes()->sync($request->redes);
116 | }
117 | else {
118 | $role->redes()->detach();
119 | }
120 |
121 | // Persistência
122 | $role->nome = $request->nome;
123 |
124 | if(!empty($request->grupoadmin))
125 | $role->grupoadmin = true;
126 | else
127 | $role->grupoadmin = false;
128 |
129 | $role->save();
130 |
131 | $request->session()->flash('alert-success', 'Grupo atualizado com sucesso!');
132 | return redirect()->route('roles.show', $role->id);
133 | }
134 |
135 | /**
136 | * Remove the specified resource from storage.
137 | *
138 | * @param \App\Role $role
139 | * @return \Illuminate\Http\Response
140 | */
141 | public function destroy(Role $role)
142 | {
143 | // Remove pessoas desse grupo
144 | $role->users()->detach();
145 |
146 | // Remove redes desse grupo
147 | $role->redes()->detach();
148 |
149 | // Remove grupo
150 | $role->delete();
151 | return redirect()->route('roles.index')->with('alert-danger', 'Grupo deletado!');
152 | }
153 | }
154 |
--------------------------------------------------------------------------------
/app/Http/Controllers/UserController.php:
--------------------------------------------------------------------------------
1 | middleware('can:admin');
15 | }
16 |
17 | /**
18 | * Display a listing of the resource.
19 | *
20 | * @return \Illuminate\Http\Response
21 | */
22 | public function index()
23 | {
24 | $users = User::paginate(20);
25 | return view('users.index')->with('users', $users);
26 | }
27 |
28 | /**
29 | * Show the form for creating a new resource.
30 | *
31 | * @return \Illuminate\Http\Response
32 | */
33 | public function create()
34 | {
35 | die('not implemented yet, bye!');
36 | }
37 |
38 | /**
39 | * Store a newly created resource in storage.
40 | *
41 | * @param \Illuminate\Http\Request $request
42 | * @return \Illuminate\Http\Response
43 | */
44 | public function store(Request $request)
45 | {
46 | die('not implemented, bye!');
47 | }
48 |
49 | /**
50 | * Display the specified resource.
51 | *
52 | * @return \Illuminate\Http\Response
53 | */
54 | public function show($username)
55 | {
56 | $user = User::where('username', $username)->first();
57 | return view('users.show', compact('user'));
58 | }
59 |
60 | /**
61 | * Show the form for editing the specified resource.
62 | *
63 | * @return \Illuminate\Http\Response
64 | */
65 | public function edit($username)
66 | {
67 | $roles = Role::all();
68 | $user = User::where('username', $username)->first();
69 | return view('users.edit', compact('user','roles'));
70 | }
71 |
72 | /**
73 | * Update the specified resource in storage.
74 | *
75 | * @param \Illuminate\Http\Request $request
76 | * @return \Illuminate\Http\Response
77 | */
78 | public function update(Request $request, $username)
79 | {
80 | $user = User::where('username', $username)->first();
81 | // redes
82 | if(!empty($request->roles)){
83 | $user->roles()->sync($request->roles);
84 | }
85 | else {
86 | $user->roles()->detach();
87 | }
88 |
89 | $request->session()->flash('alert-success', 'Pessoa atualizada com sucesso!');
90 | return redirect()->route('users.show',$user->username);
91 |
92 | }
93 |
94 | /**
95 | * Remove the specified resource from storage.
96 | *
97 | * @param \App\User $user
98 | * @return \Illuminate\Http\Response
99 | */
100 | public function destroy($username)
101 | {
102 | $user = User::where('username', $username)->first();
103 | die('not implemented, bye!');
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/app/Http/Kernel.php:
--------------------------------------------------------------------------------
1 | [
31 | \App\Http\Middleware\EncryptCookies::class,
32 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
33 | \Illuminate\Session\Middleware\StartSession::class,
34 | // \Illuminate\Session\Middleware\AuthenticateSession::class,
35 | \Illuminate\View\Middleware\ShareErrorsFromSession::class,
36 | \App\Http\Middleware\VerifyCsrfToken::class,
37 | \Illuminate\Routing\Middleware\SubstituteBindings::class,
38 | ],
39 |
40 | 'api' => [
41 | 'throttle:60,1',
42 | 'bindings',
43 | ],
44 | ];
45 |
46 | /**
47 | * The application's route middleware.
48 | *
49 | * These middleware may be assigned to groups or used individually.
50 | *
51 | * @var array
52 | */
53 | protected $routeMiddleware = [
54 | 'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
55 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
56 | 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
57 | 'can' => \Illuminate\Auth\Middleware\Authorize::class,
58 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
59 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
60 | ];
61 | }
62 |
--------------------------------------------------------------------------------
/app/Http/Middleware/EncryptCookies.php:
--------------------------------------------------------------------------------
1 | check()) {
21 | return redirect('/');
22 | }
23 |
24 | return $next($request);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/Http/Middleware/TrimStrings.php:
--------------------------------------------------------------------------------
1 | ['nullable', new Patrimonio],
34 | 'macaddress' => ['required', new MacAddress],
35 | 'descricao' => ['nullable'],
36 | 'local' => '',
37 | 'vencimento' => 'nullable|date_format:"d/m/Y"|after:today',
38 | 'rede_id' => ['required', Rule::in(Rede::allowed()->get()->pluck('id'))],
39 | 'ip' => ['nullable','ip',],
40 | ];
41 | if ($this->method() == 'PATCH' || $this->method() == 'PUT'){
42 | array_push($rules['macaddress'], 'unique:equipamentos,macaddress,'.$this->equipamento->id);
43 | } else{
44 | array_push($rules['macaddress'], 'unique:equipamentos');
45 | }
46 |
47 | if(!is_null($this->rede_id) && !empty($this->rede_id)){
48 | $rede = Rede::find($this->rede_id);
49 | array_push($rules['ip'], new PertenceRede($rede->iprede,$rede->cidr));
50 | }
51 |
52 | return $rules;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/app/Http/Requests/RedeRequest.php:
--------------------------------------------------------------------------------
1 | ['required'],
32 | 'shared_network' => 'required',
33 | 'iprede' => ['ip','required','different:gateway'],
34 | 'cidr' => 'required|integer|min:8|max:30',
35 | 'vlan' => 'integer',
36 | 'gateway' => ['ip','required', new PertenceRede($this->iprede, $this->cidr)],
37 | 'dns' => [new MultiplesIP('DNS')],
38 | 'netbios' => [new MultiplesIP('NetBIOS')],
39 | 'ad_domain' => [new Domain('Active Directory Domain')],
40 | 'ntp' => [new MultiplesIP('NTP')],
41 | 'active_dhcp' => 'nullable|boolean',
42 | 'active_freeradius' => 'nullable|boolean',
43 | 'dhcpd_subnet_options' => 'nullable',
44 | ];
45 | if ($this->method() == 'PATCH' || $this->method() == 'PUT'){
46 | array_push($rules['nome'], 'unique:redes,nome,' .$this->rede->id);
47 | array_push($rules['iprede'], new RedeCidr($this->cidr,$this->iprede,$this->rede->id));
48 | } else {
49 | array_push($rules['nome'], 'unique:redes');
50 | array_push($rules['iprede'], new RedeCidr($this->cidr,$this->iprede));
51 | }
52 | return $rules;
53 | }
54 |
55 | protected function prepareForValidation()
56 | {
57 | $this->merge([
58 | 'active_dhcp' => isset($this->active_dhcp) ? $this->active_dhcp:0,
59 | 'active_freeradius' => isset($this->active_freeradius) ? $this->active_freeradius:0,
60 | ]);
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/app/Models/Config.php:
--------------------------------------------------------------------------------
1 | belongsTo(Equipamento::class);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/app/Models/Rede.php:
--------------------------------------------------------------------------------
1 | hasMany(Equipamento::class);
29 | }
30 |
31 | public function user()
32 | {
33 | return $this->belongsTo(User::class);
34 | }
35 |
36 | public function roles()
37 | {
38 | return $this->belongsToMany(Role::class,'role_rede');
39 | }
40 |
41 | public function hasRole($role)
42 | {
43 | return null !== $this->roles()->where('nome', $role)->first();
44 | }
45 |
46 | /* Método que retorna as redes que o usuário logado tem acesso */
47 | public function scopeAllowed($query)
48 | {
49 | /* Usuários administradores podem acessar todas redes */
50 | if( Gate::allows('admin') ) {
51 | return $query;
52 | }
53 |
54 | $user = auth()->user();
55 | $redes = [];
56 | foreach($user->roles()->get() as $role){
57 | foreach($role->redes()->get() as $rede){
58 | array_push($redes,$rede->id);
59 | }
60 | }
61 | $query->OrWhereIn('id',array_unique($redes));
62 | return $query;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/app/Models/Role.php:
--------------------------------------------------------------------------------
1 | belongsToMany(User::class);
16 | }
17 |
18 | public function redes()
19 | {
20 | return $this->belongsToMany(Rede::class,'role_rede');
21 | }
22 |
23 | public function hasAnyRede($redes)
24 | {
25 | return null !== $this->redes()->whereIn('nome', $redes)->first();
26 | }
27 |
28 | public function hasRede($rede_id)
29 | {
30 | return null !== $this->redes()->where('rede_id', $rede_id)->first();
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/app/Models/User.php:
--------------------------------------------------------------------------------
1 | belongsToMany(Role::class);
36 | }
37 |
38 | /**
39 | * Check multiple roles
40 | * @param array $roles
41 | */
42 | public function hasAnyRole($roles)
43 | {
44 | return null !== $this->roles()->whereIn('nome', $roles)->first();
45 | }
46 |
47 | /**
48 | * Check one role
49 | * @param string $role
50 | */
51 | public function hasRole($role)
52 | {
53 | return null !== $this->roles()->where('nome', $role)->first();
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/app/Observers/EquipamentoObserver.php:
--------------------------------------------------------------------------------
1 | rede_id)) {
27 | Freeradius::cadastraOuAtualizaEquipamento($equipamento);
28 | }
29 | }
30 |
31 | /**
32 | * Handle the Equipamento "updated" event.
33 | *
34 | * @param \App\Models\Equipamento $equipamento
35 | * @return void
36 | */
37 | public function updated(Equipamento $equipamento)
38 | {
39 | $macaddress_antigo = $equipamento->getOriginal('macaddress');
40 |
41 | // atualiza equipamento no freeRadius
42 | if (config('copaco.freeradius_habilitar') && !is_null($equipamento->rede_id)) {
43 | Freeradius::cadastraOuAtualizaEquipamento($equipamento, $macaddress_antigo);
44 | }
45 | }
46 |
47 | /**
48 | * Handle the Equipamento "deleted" event.
49 | *
50 | * @param \App\Models\Equipamento $equipamento
51 | * @return void
52 | */
53 | public function deleted(Equipamento $equipamento)
54 | {
55 | if (config('copaco.freeradius_habilitar')) {
56 | Freeradius::deletaEquipamento($equipamento);
57 | }
58 | }
59 |
60 | /**
61 | * Handle the Equipamento "restored" event.
62 | *
63 | * @param \App\Models\Equipamento $equipamento
64 | * @return void
65 | */
66 | public function restored(Equipamento $equipamento)
67 | {
68 | //
69 | }
70 |
71 | /**
72 | * Handle the Equipamento "force deleted" event.
73 | *
74 | * @param \App\Models\Equipamento $equipamento
75 | * @return void
76 | */
77 | public function forceDeleted(Equipamento $equipamento)
78 | {
79 |
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/app/Observers/RedeObserver.php:
--------------------------------------------------------------------------------
1 | equipamentos as $equipamento) {
57 | if (config('copaco.freeradius_habilitar')) {
58 | Freeradius::deletaEquipamento($equipamento);
59 | }
60 | }
61 | Freeradius::deletaRede($rede);
62 | }
63 | }
64 |
65 | /**
66 | * Handle the Rede "restored" event.
67 | *
68 | * @param \App\Models\Rede $rede
69 | * @return void
70 | */
71 | public function restored(Rede $rede)
72 | {
73 | //
74 | }
75 |
76 | /**
77 | * Handle the Rede "force deleted" event.
78 | *
79 | * @param \App\Models\Rede $rede
80 | * @return void
81 | */
82 | public function forceDeleted(Rede $rede)
83 | {
84 | //
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/app/Policies/EquipamentoPolicy.php:
--------------------------------------------------------------------------------
1 | is_superAdmin = Gate::allows('admin') ;
27 | }
28 |
29 | public function update(User $user, Equipamento $equipamento)
30 | {
31 | $owner = $user->id === $equipamento->user_id;
32 | return $owner || $this->is_superAdmin || $this->temAcessoNaRedeDeUmAdminGrupo($user,$equipamento);
33 | }
34 |
35 | public function view(User $user, Equipamento $equipamento)
36 | {
37 | $owner = $user->id === $equipamento->user_id;
38 | return $owner || $this->is_superAdmin || $this->temAcessoNaRedeDeUmAdminGrupo($user,$equipamento);
39 | }
40 |
41 | public function delete(User $user, Equipamento $equipamento)
42 | {
43 | $owner = $user->id === $equipamento->user_id;
44 | return $owner || $this->is_superAdmin || $this->temAcessoNaRedeDeUmAdminGrupo($user,$equipamento);
45 | }
46 |
47 | public function create(User $user)
48 | {
49 | return true;
50 | }
51 |
52 | public function temAcessoNaRedeDeUmAdminGrupo($user,$equipamento)
53 | {
54 | $rede_id = $equipamento->rede_id;
55 | foreach($user->roles()->get() as $role){
56 | foreach($role->redes()->get() as $rede){
57 | if($role && $rede->id==$rede_id) {
58 | return true;
59 | }
60 | }
61 | }
62 | return false;
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/app/Providers/AppServiceProvider.php:
--------------------------------------------------------------------------------
1 | EquipamentoPolicy::class,
21 | ];
22 |
23 | /**
24 | * Register any authentication / authorization services.
25 | *
26 | * @return void
27 | */
28 | public function boot()
29 | {
30 |
31 | # equipamentos policy
32 | Gate::resource('equipamentos', 'App\Policies\EquipamentoPolicy');
33 |
34 | # admin
35 | Gate::define('admin', function ($user) {
36 | $admins = explode(',', trim(config('copaco.superadmins_usernames')));
37 | return ( in_array($user->username, $admins) and $user->username );
38 | });
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/Providers/BroadcastServiceProvider.php:
--------------------------------------------------------------------------------
1 | [
17 | 'App\Listeners\EventListener',
18 | ],
19 | ];
20 |
21 | /**
22 | * Register any events for your application.
23 | *
24 | * @return void
25 | */
26 | public function boot()
27 | {
28 | parent::boot();
29 |
30 | //
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/app/Providers/RouteServiceProvider.php:
--------------------------------------------------------------------------------
1 | mapApiRoutes();
39 |
40 | $this->mapWebRoutes();
41 |
42 | //
43 | }
44 |
45 | /**
46 | * Define the "web" routes for the application.
47 | *
48 | * These routes all receive session state, CSRF protection, etc.
49 | *
50 | * @return void
51 | */
52 | protected function mapWebRoutes()
53 | {
54 | Route::middleware('web')
55 | ->namespace($this->namespace)
56 | ->group(base_path('routes/web.php'));
57 | }
58 |
59 | /**
60 | * Define the "api" routes for the application.
61 | *
62 | * These routes are typically stateless.
63 | *
64 | * @return void
65 | */
66 | protected function mapApiRoutes()
67 | {
68 | Route::prefix('api')
69 | ->middleware('api')
70 | ->namespace($this->namespace)
71 | ->group(base_path('routes/api.php'));
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/app/Rules/CodigoAcesso.php:
--------------------------------------------------------------------------------
1 | field = $field;
19 | }
20 |
21 | /**
22 | * Determine if the validation rule passes.
23 | *
24 | * @param string $attribute
25 | * @param mixed $value
26 | * @return bool
27 | */
28 | public function passes($attribute, $value)
29 | {
30 | if ( !(v::domain()->validate(trim($value)) or empty($value) )) {
31 | return false;
32 | }
33 | return true;
34 | }
35 |
36 | /**
37 | * Get the validation error message.
38 | *
39 | * @return string
40 | */
41 | public function message()
42 | {
43 | return $this->field . ': Um domínio válido é requerido';
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/app/Rules/MacAddress.php:
--------------------------------------------------------------------------------
1 | validate($value) ) {
30 | /* Neste momento o mac é válido, mas se tiver -
31 | * o dhcp não sobe */
32 | if (strpos($value, '-') !== false){
33 | return false;
34 | }
35 | return true;
36 | }
37 | return false;
38 | }
39 |
40 | /**
41 | * Get the validation error message.
42 | *
43 | * @return string
44 | */
45 | public function message()
46 | {
47 | return 'Mac Address não é válido';
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/app/Rules/MultiplesIP.php:
--------------------------------------------------------------------------------
1 | field = $field;
19 | }
20 |
21 | /**
22 | * Determine if the validation rule passes.
23 | *
24 | * @param string $attribute
25 | * @param mixed $value
26 | * @return bool
27 | */
28 | public function passes($attribute, $value)
29 | {
30 | $values = explode(',',$value);
31 | foreach($values as $v) {
32 | if ( !(v::ip()->validate(trim($v)) or empty($v) )) {
33 | return false;
34 | }
35 | }
36 | return true;
37 | }
38 |
39 | /**
40 | * Get the validation error message.
41 | *
42 | * @return string
43 | */
44 | public function message()
45 | {
46 | return $this->field . ': IP(s) válido(s) é(são) requerido(s)';
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/app/Rules/Patrimonio.php:
--------------------------------------------------------------------------------
1 | iprede = $iprede;
21 | $this->cidr = $cidr;
22 | }
23 |
24 | /**
25 | * Determine if the validation rule passes.
26 | *
27 | * @param string $attribute
28 | * @param mixed $value
29 | * @return bool
30 | */
31 | public function passes($attribute, $value)
32 | {
33 | return NetworkOps::pertenceRede($value, $this->iprede, $this->cidr);
34 | }
35 |
36 | /**
37 | * Get the validation error message.
38 | *
39 | * @return string
40 | */
41 | public function message()
42 | {
43 | return 'O :attribute não está no range da rede';
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/app/Rules/RedeCidr.php:
--------------------------------------------------------------------------------
1 | rede_id = $rede_id;
22 | $this->ip_rede = $ip_rede;
23 | $this->cidr = $cidr;
24 | }
25 |
26 | /**
27 | * Determine if the validation rule passes.
28 | *
29 | * @param string $attribute
30 | * @param mixed $value
31 | * @return bool
32 | */
33 | public function passes($ip_rede, $value)
34 | {
35 | $redes = Rede::where('iprede', $value)
36 | ->get()
37 | ->except($this->rede_id);
38 | # Se NÃO contiver o cidr, retorna true
39 | return !$redes->contains('cidr', $this->cidr);
40 | }
41 |
42 | /**
43 | * Get the validation error message.
44 | *
45 | * @return string
46 | */
47 | public function message()
48 | {
49 | return "A rede $this->ip_rede/$this->cidr já existe neste sistema.";
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/app/Utils/Utils.php:
--------------------------------------------------------------------------------
1 | first();
16 | $equipamento = Equipamento::orderBy('updated_at', 'DESC')->first();
17 |
18 | $rede = Carbon::createFromFormat('Y-m-d H:i:s', $rede->updated_at);
19 | $equipamento = Carbon::createFromFormat('Y-m-d H:i:s', $equipamento->updated_at);
20 |
21 | if($rede->greaterThan($equipamento)){
22 | return $rede->format('d/m/Y H:i:s');
23 | }
24 | return $equipamento->format('d/m/Y H:i:s');
25 | }
26 |
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/artisan:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env php
2 | make(Illuminate\Contracts\Console\Kernel::class);
34 |
35 | $status = $kernel->handle(
36 | $input = new Symfony\Component\Console\Input\ArgvInput,
37 | new Symfony\Component\Console\Output\ConsoleOutput
38 | );
39 |
40 | /*
41 | |--------------------------------------------------------------------------
42 | | Shutdown The Application
43 | |--------------------------------------------------------------------------
44 | |
45 | | Once Artisan has finished running, we will fire off the shutdown events
46 | | so that any final work may be done by the application before we shut
47 | | down the process. This is the last thing to happen to the request.
48 | |
49 | */
50 |
51 | $kernel->terminate($input, $status);
52 |
53 | exit($status);
54 |
--------------------------------------------------------------------------------
/bootstrap/app.php:
--------------------------------------------------------------------------------
1 | singleton(
30 | Illuminate\Contracts\Http\Kernel::class,
31 | App\Http\Kernel::class
32 | );
33 |
34 | $app->singleton(
35 | Illuminate\Contracts\Console\Kernel::class,
36 | App\Console\Kernel::class
37 | );
38 |
39 | $app->singleton(
40 | Illuminate\Contracts\Debug\ExceptionHandler::class,
41 | App\Exceptions\Handler::class
42 | );
43 |
44 | /*
45 | |--------------------------------------------------------------------------
46 | | Return The Application
47 | |--------------------------------------------------------------------------
48 | |
49 | | This script returns the application instance. The instance is given to
50 | | the calling script so we can separate the building of the instances
51 | | from the actual running of the application and sending responses.
52 | |
53 | */
54 |
55 | return $app;
56 |
--------------------------------------------------------------------------------
/bootstrap/cache/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "laravel/laravel",
3 | "type": "project",
4 | "description": "The Laravel Framework.",
5 | "keywords": [
6 | "framework",
7 | "laravel"
8 | ],
9 | "license": "MIT",
10 | "require": {
11 | "php": "^8.3",
12 | "doctrine/dbal": "^3.1",
13 | "guzzlehttp/guzzle": "^7.0.1",
14 | "laravel/framework": "^11.0",
15 | "laravel/helpers": "^1.2",
16 | "laravel/tinker": "^2.0",
17 | "laravel/ui": "^4.0",
18 | "maatwebsite/excel": "^3.1",
19 | "owen-it/laravel-auditing": "^13.6.8",
20 | "rap2hpoutre/laravel-log-viewer": "^2.4.0",
21 | "respect/validation": "^2.0",
22 | "s1lentium/iptools": "^1.1",
23 | "uspdev/laravel-usp-theme": "^2.0",
24 | "uspdev/senhaunica-socialite": "^4.0"
25 | },
26 | "require-dev": {
27 | "spatie/laravel-ignition": "^2.0",
28 | "fakerphp/faker": "^1.9.1",
29 | "mockery/mockery": "^1.3.1",
30 | "nunomaduro/collision": "^8.1",
31 | "phpunit/phpunit": "^10.0"
32 | },
33 | "config": {
34 | "optimize-autoloader": true,
35 | "preferred-install": "dist",
36 | "sort-packages": true
37 | },
38 | "extra": {
39 | "laravel": {
40 | "dont-discover": []
41 | }
42 | },
43 | "autoload": {
44 | "psr-4": {
45 | "App\\": "app/",
46 | "Database\\Factories\\": "database/factories/",
47 | "Database\\Seeders\\": "database/seeders/"
48 | }
49 | },
50 | "autoload-dev": {
51 | "psr-4": {
52 | "Tests\\": "tests/"
53 | }
54 | },
55 | "minimum-stability": "stable",
56 | "prefer-stable": true,
57 | "scripts": {
58 | "post-autoload-dump": [
59 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
60 | "@php artisan package:discover --ansi",
61 | "@php artisan vendor:publish --provider='Uspdev\\UspTheme\\ServiceProvider' --tag=assets --force"
62 | ],
63 | "post-root-package-install": [
64 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
65 | ],
66 | "post-create-project-cmd": [
67 | "@php artisan key:generate --ansi"
68 | ]
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/config/audit.php:
--------------------------------------------------------------------------------
1 | env('AUDITING_ENABLED', true),
6 |
7 | /*
8 | |--------------------------------------------------------------------------
9 | | Audit Implementation
10 | |--------------------------------------------------------------------------
11 | |
12 | | Define which Audit model implementation should be used.
13 | |
14 | */
15 |
16 | 'implementation' => OwenIt\Auditing\Models\Audit::class,
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | User Morph prefix & Guards
21 | |--------------------------------------------------------------------------
22 | |
23 | | Define the morph prefix and authentication guards for the User resolver.
24 | |
25 | */
26 |
27 | 'user' => [
28 | 'morph_prefix' => 'user',
29 | 'guards' => [
30 | 'web',
31 | 'api',
32 | ],
33 | ],
34 |
35 | /*
36 | |--------------------------------------------------------------------------
37 | | Audit Resolvers
38 | |--------------------------------------------------------------------------
39 | |
40 | | Define the User, IP Address, User Agent and URL resolver implementations.
41 | |
42 | */
43 | 'resolver' => [
44 | 'user' => OwenIt\Auditing\Resolvers\UserResolver::class,
45 | 'ip_address' => OwenIt\Auditing\Resolvers\IpAddressResolver::class,
46 | 'user_agent' => OwenIt\Auditing\Resolvers\UserAgentResolver::class,
47 | 'url' => OwenIt\Auditing\Resolvers\UrlResolver::class,
48 | ],
49 |
50 | /*
51 | |--------------------------------------------------------------------------
52 | | Audit Events
53 | |--------------------------------------------------------------------------
54 | |
55 | | The Eloquent events that trigger an Audit.
56 | |
57 | */
58 |
59 | 'events' => [
60 | 'created',
61 | 'updated',
62 | 'deleted',
63 | 'restored',
64 | ],
65 |
66 | /*
67 | |--------------------------------------------------------------------------
68 | | Strict Mode
69 | |--------------------------------------------------------------------------
70 | |
71 | | Enable the strict mode when auditing?
72 | |
73 | */
74 |
75 | 'strict' => false,
76 |
77 | /*
78 | |--------------------------------------------------------------------------
79 | | Audit Timestamps
80 | |--------------------------------------------------------------------------
81 | |
82 | | Should the created_at, updated_at and deleted_at timestamps be audited?
83 | |
84 | */
85 |
86 | 'timestamps' => false,
87 |
88 | /*
89 | |--------------------------------------------------------------------------
90 | | Audit Threshold
91 | |--------------------------------------------------------------------------
92 | |
93 | | Specify a threshold for the amount of Audit records a model can have.
94 | | Zero means no limit.
95 | |
96 | */
97 |
98 | 'threshold' => 0,
99 |
100 | /*
101 | |--------------------------------------------------------------------------
102 | | Audit Driver
103 | |--------------------------------------------------------------------------
104 | |
105 | | The default audit driver used to keep track of changes.
106 | |
107 | */
108 |
109 | 'driver' => 'database',
110 |
111 | /*
112 | |--------------------------------------------------------------------------
113 | | Audit Driver Configurations
114 | |--------------------------------------------------------------------------
115 | |
116 | | Available audit drivers and respective configurations.
117 | |
118 | */
119 |
120 | 'drivers' => [
121 | 'database' => [
122 | 'table' => 'audits',
123 | 'connection' => null,
124 | ],
125 | ],
126 |
127 | /*
128 | |--------------------------------------------------------------------------
129 | | Audit Console
130 | |--------------------------------------------------------------------------
131 | |
132 | | Whether console events should be audited (eg. php artisan db:seed).
133 | |
134 | */
135 |
136 | 'console' => false,
137 | ];
138 |
--------------------------------------------------------------------------------
/config/auth.php:
--------------------------------------------------------------------------------
1 | [
17 | 'guard' => 'web',
18 | 'passwords' => 'users',
19 | ],
20 |
21 | /*
22 | |--------------------------------------------------------------------------
23 | | Authentication Guards
24 | |--------------------------------------------------------------------------
25 | |
26 | | Next, you may define every authentication guard for your application.
27 | | Of course, a great default configuration has been defined for you
28 | | here which uses session storage and the Eloquent user provider.
29 | |
30 | | All authentication drivers have a user provider. This defines how the
31 | | users are actually retrieved out of your database or other storage
32 | | mechanisms used by this application to persist your user's data.
33 | |
34 | | Supported: "session", "token"
35 | |
36 | */
37 |
38 | 'guards' => [
39 | 'web' => [
40 | 'driver' => 'session',
41 | 'provider' => 'users',
42 | ],
43 |
44 | 'api' => [
45 | 'driver' => 'token',
46 | 'provider' => 'users',
47 | ],
48 | ],
49 |
50 | /*
51 | |--------------------------------------------------------------------------
52 | | User Providers
53 | |--------------------------------------------------------------------------
54 | |
55 | | All authentication drivers have a user provider. This defines how the
56 | | users are actually retrieved out of your database or other storage
57 | | mechanisms used by this application to persist your user's data.
58 | |
59 | | If you have multiple user tables or models you may configure multiple
60 | | sources which represent each model / table. These sources may then
61 | | be assigned to any extra authentication guards you have defined.
62 | |
63 | | Supported: "database", "eloquent"
64 | |
65 | */
66 |
67 | 'providers' => [
68 | 'users' => [
69 | 'driver' => 'eloquent',
70 | 'model' => App\Models\User::class,
71 | ],
72 |
73 | // 'users' => [
74 | // 'driver' => 'database',
75 | // 'table' => 'users',
76 | // ],
77 | ],
78 |
79 | /*
80 | |--------------------------------------------------------------------------
81 | | Resetting Passwords
82 | |--------------------------------------------------------------------------
83 | |
84 | | You may specify multiple password reset configurations if you have more
85 | | than one user table or model in the application and you want to have
86 | | separate password reset settings based on the specific user types.
87 | |
88 | | The expire time is the number of minutes that the reset token should be
89 | | considered valid. This security feature keeps tokens short-lived so
90 | | they have less time to be guessed. You may change this as needed.
91 | |
92 | */
93 |
94 | 'passwords' => [
95 | 'users' => [
96 | 'provider' => 'users',
97 | 'table' => 'password_resets',
98 | 'expire' => 60,
99 | ],
100 | ],
101 |
102 | ];
103 |
--------------------------------------------------------------------------------
/config/broadcasting.php:
--------------------------------------------------------------------------------
1 | env('BROADCAST_DRIVER', 'null'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Broadcast Connections
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may define all of the broadcast connections that will be used
26 | | to broadcast events to other systems or over websockets. Samples of
27 | | each available type of connection are provided inside this array.
28 | |
29 | */
30 |
31 | 'connections' => [
32 |
33 | 'pusher' => [
34 | 'driver' => 'pusher',
35 | 'key' => env('PUSHER_APP_KEY'),
36 | 'secret' => env('PUSHER_APP_SECRET'),
37 | 'app_id' => env('PUSHER_APP_ID'),
38 | 'options' => [
39 | 'cluster' => env('PUSHER_APP_CLUSTER'),
40 | 'encrypted' => true,
41 | ],
42 | ],
43 |
44 | 'redis' => [
45 | 'driver' => 'redis',
46 | 'connection' => 'default',
47 | ],
48 |
49 | 'log' => [
50 | 'driver' => 'log',
51 | ],
52 |
53 | 'null' => [
54 | 'driver' => 'null',
55 | ],
56 |
57 | ],
58 |
59 | ];
60 |
--------------------------------------------------------------------------------
/config/cache.php:
--------------------------------------------------------------------------------
1 | env('CACHE_DRIVER', 'file'),
22 |
23 | /*
24 | |--------------------------------------------------------------------------
25 | | Cache Stores
26 | |--------------------------------------------------------------------------
27 | |
28 | | Here you may define all of the cache "stores" for your application as
29 | | well as their drivers. You may even define multiple stores for the
30 | | same cache driver to group types of items stored in your caches.
31 | |
32 | */
33 |
34 | 'stores' => [
35 |
36 | 'apc' => [
37 | 'driver' => 'apc',
38 | ],
39 |
40 | 'array' => [
41 | 'driver' => 'array',
42 | 'serialize' => false,
43 | ],
44 |
45 | 'database' => [
46 | 'driver' => 'database',
47 | 'table' => 'cache',
48 | 'connection' => null,
49 | ],
50 |
51 | 'file' => [
52 | 'driver' => 'file',
53 | 'path' => storage_path('framework/cache/data'),
54 | ],
55 |
56 | 'memcached' => [
57 | 'driver' => 'memcached',
58 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
59 | 'sasl' => [
60 | env('MEMCACHED_USERNAME'),
61 | env('MEMCACHED_PASSWORD'),
62 | ],
63 | 'options' => [
64 | // Memcached::OPT_CONNECT_TIMEOUT => 2000,
65 | ],
66 | 'servers' => [
67 | [
68 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'),
69 | 'port' => env('MEMCACHED_PORT', 11211),
70 | 'weight' => 100,
71 | ],
72 | ],
73 | ],
74 |
75 | 'redis' => [
76 | 'driver' => 'redis',
77 | 'connection' => 'cache',
78 | ],
79 |
80 | 'dynamodb' => [
81 | 'driver' => 'dynamodb',
82 | 'key' => env('AWS_ACCESS_KEY_ID'),
83 | 'secret' => env('AWS_SECRET_ACCESS_KEY'),
84 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
85 | 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
86 | 'endpoint' => env('DYNAMODB_ENDPOINT'),
87 | ],
88 |
89 | ],
90 |
91 | /*
92 | |--------------------------------------------------------------------------
93 | | Cache Key Prefix
94 | |--------------------------------------------------------------------------
95 | |
96 | | When utilizing a RAM based store such as APC or Memcached, there might
97 | | be other applications utilizing the same cache. So, we'll specify a
98 | | value to get prefixed to all our keys so we can avoid collisions.
99 | |
100 | */
101 |
102 | 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'),
103 |
104 | ];
105 |
--------------------------------------------------------------------------------
/config/copaco.php:
--------------------------------------------------------------------------------
1 | env('CODIGO_ACESSO', false),
15 | 'somente_senhaunica' => env('SOMENTE_SENHAUNICA', false),
16 | /*
17 | |--------------------------------------------------------------------------
18 | | Senha Única
19 | |--------------------------------------------------------------------------
20 | | TODO: DOCUMENTAR VARIÁVEIS
21 | */
22 |
23 | 'senha_unica_key' => env('SENHAUNICA_KEY', false),
24 | 'senha_unica_secret' => env('SENHAUNICA_SECRET', false),
25 | 'senha_unica_callback_id' => env('SENHAUNICA_CALLBACK_ID', false),
26 |
27 | # Unidades autorizadas
28 | 'senha_unica_unidades' => env('SENHAUNICA_UNIDADES'),
29 |
30 | # permitir login de todos, aluno etc
31 | 'allow_login_all' => env('ALLOW_LOGIN_ALL',0),
32 |
33 | # Admins
34 | 'superadmins_usernames' => env('SUPERADMINS_USERNAMES'),
35 |
36 | /*
37 | |--------------------------------------------------------------------------
38 | | DHCP e FreeRadius
39 | |--------------------------------------------------------------------------
40 | | consumer_deploy_key = parâmetro enviado para os servidores DHCP e FreeRadius
41 | | freeradius_macaddr_case = 'upper','lower'
42 | */
43 | 'consumer_deploy_key' => env('CONSUMER_DEPLOY_KEY', false),
44 |
45 | 'freeradius_habilitar' => env('FREERADIUS_HABILITAR', false),
46 | 'freeradius_host' => env('FREERADIUS_HOST', 'localhost'),
47 | 'freeradius_user' => env('FREERADIUS_USER'),
48 | 'freeradius_db' => env('FREERADIUS_DB'),
49 | 'freeradius_db' => env('FREERADIUS_PASSWD'),
50 | 'freeradius_macaddr_separator' => env('FREERADIUS_MACADDR_SEPARATOR', '-'),
51 | 'freeradius_macaddr_case' => env('FREERADIUS_MACADDR_CASE', 'lower')
52 | ];
53 |
--------------------------------------------------------------------------------
/config/filesystems.php:
--------------------------------------------------------------------------------
1 | env('FILESYSTEM_DISK', 'local'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Default Cloud Filesystem Disk
21 | |--------------------------------------------------------------------------
22 | |
23 | | Many applications store files both locally and in the cloud. For this
24 | | reason, you may specify a default "cloud" driver here. This driver
25 | | will be bound as the Cloud disk implementation in the container.
26 | |
27 | */
28 |
29 | 'cloud' => env('FILESYSTEM_CLOUD', 's3'),
30 |
31 | /*
32 | |--------------------------------------------------------------------------
33 | | Filesystem Disks
34 | |--------------------------------------------------------------------------
35 | |
36 | | Here you may configure as many filesystem "disks" as you wish, and you
37 | | may even configure multiple disks of the same driver. Defaults have
38 | | been setup for each driver as an example of the required options.
39 | |
40 | | Supported Drivers: "local", "ftp", "s3", "rackspace"
41 | |
42 | */
43 |
44 | 'disks' => [
45 |
46 | 'local' => [
47 | 'driver' => 'local',
48 | 'root' => storage_path('app'),
49 | ],
50 |
51 | 'public' => [
52 | 'driver' => 'local',
53 | 'root' => storage_path('app/public'),
54 | 'url' => env('APP_URL').'/storage',
55 | 'visibility' => 'public',
56 | 'throw' => true,
57 | ],
58 |
59 | 's3' => [
60 | 'driver' => 's3',
61 | 'key' => env('AWS_ACCESS_KEY_ID'),
62 | 'secret' => env('AWS_SECRET_ACCESS_KEY'),
63 | 'region' => env('AWS_DEFAULT_REGION'),
64 | 'bucket' => env('AWS_BUCKET'),
65 | ],
66 |
67 | ],
68 |
69 | ];
70 |
--------------------------------------------------------------------------------
/config/laravel-usp-theme-sistemas.php:
--------------------------------------------------------------------------------
1 | $value) {
5 | if (strpos($key, $prefix) !== false) {
6 | $sistemas[] = json_decode($value, true);
7 | }
8 | }
9 |
10 | return [
11 | 'sistemas' => $sistemas,
12 | ];
--------------------------------------------------------------------------------
/config/laravel-usp-theme.php:
--------------------------------------------------------------------------------
1 | 'Cadastrar',
6 | 'url' => config('app.url') . '/redes/create',
7 | ],
8 | [
9 | 'text' => 'Listar',
10 | 'url' => config('app.url') . '/redes',
11 | ],
12 | [
13 | 'text' => 'Migrar equipamentos entre redes',
14 | 'url' => config('app.url') . '/redes/migrate',
15 | ],
16 | ];
17 |
18 | $right_menu = [
19 | [
20 | 'text' => ' ',
21 | 'title' => 'logs',
22 | 'target' => '_blank',
23 | 'url' => config('app.url') . '/logs',
24 | 'align' => 'right',
25 | 'can' => 'admin',
26 | ],
27 | ];
28 |
29 | return [
30 | 'title' => '',
31 | 'skin' => env('USP_THEME_SKIN', 'uspdev'),
32 | 'app_url' => config('app.url'),
33 | 'logout_method' => 'POST',
34 | 'logout_url' => config('app.url') . '/logout',
35 | 'login_url' => config('app.url') . '/login',
36 |
37 | 'menu' => [
38 | [
39 | 'text' => 'Minha Conta',
40 | 'url' => config('app.url'),
41 | 'can' => 'equipamentos.create',
42 | ],
43 | [
44 | 'text' => 'Equipamentos',
45 | 'url' => config('app.url') . '/equipamentos',
46 | 'icon' => 'desktop',
47 | 'can' => 'equipamentos.create',
48 | ],
49 | [
50 | 'text' => 'Redes',
51 | 'icon' => 'sitemap',
52 | 'can' => 'admin',
53 | 'submenu' => $redes,
54 | ],
55 | [
56 | 'text' => 'Configurações',
57 | 'url' => config('app.url') . '/config',
58 | 'icon' => 'file',
59 | 'can' => 'admin',
60 | ],
61 | [
62 | 'text' => 'Grupos',
63 | 'url' => config('app.url') . '/roles',
64 | 'icon' => 'group',
65 | 'can' => 'admin',
66 | ],
67 | [
68 | 'text' => 'Pessoas',
69 | 'url' => config('app.url') . '/users',
70 | 'icon' => 'home',
71 | 'can' => 'admin',
72 | ],
73 | ],
74 | 'right_menu' => $right_menu,
75 | ];
76 |
--------------------------------------------------------------------------------
/config/logging.php:
--------------------------------------------------------------------------------
1 | env('LOG_CHANNEL', 'stack'),
21 |
22 | /*
23 | |--------------------------------------------------------------------------
24 | | Log Channels
25 | |--------------------------------------------------------------------------
26 | |
27 | | Here you may configure the log channels for your application. Out of
28 | | the box, Laravel uses the Monolog PHP logging library. This gives
29 | | you a variety of powerful log handlers / formatters to utilize.
30 | |
31 | | Available Drivers: "single", "daily", "slack", "syslog",
32 | | "errorlog", "monolog",
33 | | "custom", "stack"
34 | |
35 | */
36 |
37 | 'channels' => [
38 | 'stack' => [
39 | 'driver' => 'stack',
40 | 'channels' => ['single','syslog'],
41 | 'ignore_exceptions' => false,
42 | ],
43 |
44 | 'single' => [
45 | 'driver' => 'single',
46 | 'path' => storage_path('logs/laravel.log'),
47 | 'level' => env('LOG_LEVEL', 'debug'),
48 | ],
49 |
50 | 'daily' => [
51 | 'driver' => 'daily',
52 | 'path' => storage_path('logs/laravel.log'),
53 | 'level' => env('LOG_LEVEL', 'debug'),
54 | 'days' => 14,
55 | ],
56 |
57 | 'slack' => [
58 | 'driver' => 'slack',
59 | 'url' => env('LOG_SLACK_WEBHOOK_URL'),
60 | 'username' => 'Laravel Log',
61 | 'emoji' => ':boom:',
62 | 'level' => env('LOG_LEVEL', 'critical'),
63 | ],
64 |
65 | 'papertrail' => [
66 | 'driver' => 'monolog',
67 | 'level' => env('LOG_LEVEL', 'debug'),
68 | 'handler' => SyslogUdpHandler::class,
69 | 'handler_with' => [
70 | 'host' => env('PAPERTRAIL_URL'),
71 | 'port' => env('PAPERTRAIL_PORT'),
72 | ],
73 | ],
74 |
75 | 'stderr' => [
76 | 'driver' => 'monolog',
77 | 'handler' => StreamHandler::class,
78 | 'formatter' => env('LOG_STDERR_FORMATTER'),
79 | 'with' => [
80 | 'stream' => 'php://stderr',
81 | ],
82 | ],
83 |
84 | 'syslog' => [
85 | 'driver' => 'syslog',
86 | 'level' => env('LOG_LEVEL', 'debug'),
87 | ],
88 |
89 | 'errorlog' => [
90 | 'driver' => 'errorlog',
91 | 'level' => env('LOG_LEVEL', 'debug'),
92 | ],
93 |
94 | 'null' => [
95 | 'driver' => 'monolog',
96 | 'handler' => NullHandler::class,
97 | ],
98 |
99 | 'emergency' => [
100 | 'path' => storage_path('logs/laravel.log'),
101 | ],
102 | ],
103 |
104 | ];
105 |
--------------------------------------------------------------------------------
/config/queue.php:
--------------------------------------------------------------------------------
1 | env('QUEUE_DRIVER', 'sync'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Queue Connections
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may configure the connection information for each server that
26 | | is used by your application. A default configuration has been added
27 | | for each back-end shipped with Laravel. You are free to add more.
28 | |
29 | */
30 |
31 | 'connections' => [
32 |
33 | 'sync' => [
34 | 'driver' => 'sync',
35 | ],
36 |
37 | 'database' => [
38 | 'driver' => 'database',
39 | 'table' => 'jobs',
40 | 'queue' => 'default',
41 | 'retry_after' => 90,
42 | ],
43 |
44 | 'beanstalkd' => [
45 | 'driver' => 'beanstalkd',
46 | 'host' => 'localhost',
47 | 'queue' => 'default',
48 | 'retry_after' => 90,
49 | ],
50 |
51 | 'sqs' => [
52 | 'driver' => 'sqs',
53 | 'key' => env('SQS_KEY', 'your-public-key'),
54 | 'secret' => env('SQS_SECRET', 'your-secret-key'),
55 | 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
56 | 'queue' => env('SQS_QUEUE', 'your-queue-name'),
57 | 'region' => env('SQS_REGION', 'us-east-1'),
58 | ],
59 |
60 | 'redis' => [
61 | 'driver' => 'redis',
62 | 'connection' => 'default',
63 | 'queue' => 'default',
64 | 'retry_after' => 90,
65 | ],
66 |
67 | ],
68 |
69 | /*
70 | |--------------------------------------------------------------------------
71 | | Failed Queue Jobs
72 | |--------------------------------------------------------------------------
73 | |
74 | | These options configure the behavior of failed queue job logging so you
75 | | can control which database and table are used to store the jobs that
76 | | have failed. You may change them to any database / table you wish.
77 | |
78 | */
79 |
80 | 'failed' => [
81 | 'database' => env('DB_CONNECTION', 'mysql'),
82 | 'table' => 'failed_jobs',
83 | ],
84 |
85 | ];
86 |
--------------------------------------------------------------------------------
/config/senhaunica.php:
--------------------------------------------------------------------------------
1 | false, // usa rotas e controller internos
6 |
7 | // coloque um prefixo em caso de colisão de rotas
8 | // para todas as rotas internas da biblioteca (login, loginas, callback, logout e users).
9 | 'prefix' => '',
10 |
11 | 'middleware' => ['web'], // you probably want to include 'web' here
12 | 'session_key' => 'senhaunica-socialite', // chave da sessão. Troque em caso de colisão com outra variável de sessão.
13 | 'template' => 'laravel-usp-theme::master', // template a ser estendido para as views internas, deve possuir a section "content"
14 |
15 | // define as rotas para o gerenciador de usuários interno, dentro de prefix
16 | // se vazio, desabilita a rota de gerenciamento de usuários interna
17 | 'userRoutes' => 'users',
18 |
19 | // usa as permissoes internas, padrão para v4.
20 | // Se false, não usará permission ao efetuar login
21 | 'permission' => false,
22 |
23 | // permite login somente de usuários já cadastrados na base local ou autorizados nos admins, gerentes ou users
24 | 'onlyLocalUsers' => false,
25 |
26 | // se true, habilita botão para remover usuário (destroy)
27 | 'destroyUser' => false,
28 |
29 | // se true, revoga as permissões do usuario se não estiver no env.
30 | // quer dizer que as permissões serão gerenciadas todas a partir do env da aplicação.
31 | 'dropPermissions' => env('SENHAUNICA_DROP_PERMISSIONS', false),
32 |
33 | // cadastre os admins separados por virgula
34 | 'admins' => array_map('trim', explode(',', env('SENHAUNICA_ADMINS', ''))),
35 |
36 | // cadastre os gerentes separados por virgula
37 | 'gerentes' => array_map('trim', explode(',', env('SENHAUNICA_GERENTES', ''))),
38 |
39 | // se quiser cadastre os usuários comuns autorizados. Relevante se onlyLocalUsers = true
40 | 'users' => array_map('trim', explode(',', env('SENHAUNICA_USERS', ''))),
41 |
42 | 'dev' => env('SENHAUNICA_DEV', 'no'),
43 | 'debug' => (bool) env('SENHAUNICA_DEBUG', false),
44 | 'callback_id' => env('SENHAUNICA_CALLBACK_ID'),
45 |
46 | // SENHAUNICA_KEY e SENHAUNICA_SECRET são carregados em services.php da biblioteca
47 | ];
48 |
--------------------------------------------------------------------------------
/config/services.php:
--------------------------------------------------------------------------------
1 | [
18 | 'domain' => env('MAILGUN_DOMAIN'),
19 | 'secret' => env('MAILGUN_SECRET'),
20 | ],
21 |
22 | 'ses' => [
23 | 'key' => env('SES_KEY'),
24 | 'secret' => env('SES_SECRET'),
25 | 'region' => 'us-east-1',
26 | ],
27 |
28 | 'sparkpost' => [
29 | 'secret' => env('SPARKPOST_SECRET'),
30 | ],
31 |
32 | 'stripe' => [
33 | 'model' => App\Models\User::class,
34 | 'key' => env('STRIPE_KEY'),
35 | 'secret' => env('STRIPE_SECRET'),
36 | ],
37 |
38 | ];
39 |
--------------------------------------------------------------------------------
/config/view.php:
--------------------------------------------------------------------------------
1 | [
17 | resource_path('views'),
18 | ],
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Compiled View Path
23 | |--------------------------------------------------------------------------
24 | |
25 | | This option determines where all the compiled Blade templates will be
26 | | stored for your application. Typically, this is within the storage
27 | | directory. However, as usual, you are free to change this value.
28 | |
29 | */
30 |
31 | 'compiled' => realpath(storage_path('framework/views')),
32 |
33 | ];
34 |
--------------------------------------------------------------------------------
/database/.gitignore:
--------------------------------------------------------------------------------
1 | *.sqlite
2 |
--------------------------------------------------------------------------------
/database/factories/EquipamentoFactory.php:
--------------------------------------------------------------------------------
1 | inRandomOrder()->first();
29 |
30 | //Baseado no grupo ao que usuário pertence, busca-se as redes que estão disponíveis para esse grupo
31 | $role_rede = DB::table('role_rede')->where('role_id',$role_user->role_id)->inRandomOrder()->first();
32 |
33 | //Aqui retorna-se um collection da rede selecionada aleatoriamente para configuração do equipamento
34 | $rede = Rede::find($role_rede->rede_id);
35 |
36 | // Não começa em zero para excluir gateway
37 | $ip_selecionado = NetworkOps::getRandomIP($rede->iprede, $rede->cidr);
38 |
39 | return [
40 | 'patrimonio' => null,
41 | 'descricao' => $this->faker->paragraph(1),
42 | 'macaddress' => $this->faker->unique()->macAddress,
43 | 'local' => $this->faker->word,
44 | 'vencimento' => date("d/m/Y", strtotime("+".rand(30, 360)."days")),
45 | 'ip' => $ip_selecionado,
46 | 'rede_id' => $rede->id,
47 | 'user_id' => $role_user->user_id,
48 | ];
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/database/factories/FileFactory.php:
--------------------------------------------------------------------------------
1 | faker->numberBetween(21, 30);
30 |
31 | // usuários
32 | $user_modify = User::get("id")->toArray();
33 | //$user_modify = ['1','2','3','4','5'];
34 | return [
35 | 'nome' => $this->faker->unique()->domainWord() . " network",
36 | 'iprede' => $iprede,
37 | 'gateway' => NetworkOps::findFirstIP($iprede, $cidr),
38 | 'dns' => NetworkOps::getRandomIP($iprede, $cidr),
39 | 'ntp' => NetworkOps::getRandomIP($iprede, $cidr),
40 | 'netbios' => NetworkOps::getRandomIP($iprede, $cidr),
41 | 'cidr' => $cidr,
42 | 'vlan' => $this->faker->unique()->numberBetween(10, 100),
43 | 'ad_domain' => $this->faker->domainName,
44 | 'user_id' => $user_modify[array_rand($user_modify)]['id'],
45 | 'shared_network' => 'default',
46 | ];
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/database/factories/RoleFactory.php:
--------------------------------------------------------------------------------
1 | $this->faker->unique()->word,
26 | ];
27 | }
28 | }
--------------------------------------------------------------------------------
/database/factories/UserFactory.php:
--------------------------------------------------------------------------------
1 | $this->faker->unique()->name,
27 | 'email' => $this->faker->unique()->safeEmail,
28 | 'password' => bcrypt('secret'),
29 | 'username' => $this->faker->unique()->userName,
30 | ];
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/database/migrations/2014_10_12_000000_create_users_table.php:
--------------------------------------------------------------------------------
1 | increments('id');
18 | $table->string('name');
19 | $table->string('email')->unique();
20 | $table->string('password')->nullable();
21 | $table->string('username_senhaunica')->nullable();
22 | $table->string('username_ldap')->nullable();
23 | $table->rememberToken();
24 | $table->timestamps();
25 | });
26 | }
27 |
28 | /**
29 | * Reverse the migrations.
30 | *
31 | * @return void
32 | */
33 | public function down()
34 | {
35 | Schema::dropIfExists('users');
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/database/migrations/2014_10_12_100000_create_password_resets_table.php:
--------------------------------------------------------------------------------
1 | string('email')->index();
18 | $table->string('token');
19 | $table->timestamp('created_at')->nullable();
20 | });
21 | }
22 |
23 | /**
24 | * Reverse the migrations.
25 | *
26 | * @return void
27 | */
28 | public function down()
29 | {
30 | Schema::dropIfExists('password_resets');
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/database/migrations/2018_01_23_173421_create_redes_table.php:
--------------------------------------------------------------------------------
1 | increments('id');
18 | $table->timestamps();
19 | $table->string('nome');
20 | $table->ipAddress('iprede');
21 | $table->ipAddress('gateway');
22 | $table->string('dns');
23 | $table->string('ntp')->nullable();
24 | $table->string('netbios')->nullable();
25 | $table->integer('cidr');
26 | $table->integer('vlan')->nullable();
27 | $table->string('ad_domain')->nullable();
28 | $table->integer('user_id')->unsigned()->nullable();
29 | $table->foreign('user_id')->references('id')->on('users')->onDelete('set null');
30 | $table->integer('last_modify_by')->unsigned()->nullable();
31 | $table->foreign('last_modify_by')->references('id')->on('users')->onDelete('set null');
32 | });
33 | }
34 |
35 | /**
36 | * Reverse the migrations.
37 | *
38 | * @return void
39 | */
40 | public function down()
41 | {
42 | Schema::dropIfExists('equipamentos');
43 | Schema::dropIfExists('redes');
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/database/migrations/2018_01_23_180822_create_equipamentos_table.php:
--------------------------------------------------------------------------------
1 | increments('id');
18 | $table->boolean('naopatrimoniado')->default(0);
19 | $table->string('patrimonio')->nullable();
20 | $table->string('descricaosempatrimonio')->nullable();
21 | $table->macAddress('macaddress')->unique();
22 | $table->string('local')->nullable();
23 | $table->date('vencimento');
24 | $table->boolean('fixarip')->default(0);
25 | $table->ipAddress('ip')->nullable();
26 | $table->integer('rede_id')->unsigned()->nullable();
27 | $table->foreign('rede_id')->references('id')->on('redes')->onDelete('set null');
28 | $table->timestamps();
29 | $table->integer('user_id')->unsigned()->nullable();
30 | $table->foreign('user_id')->references('id')->on('users')->onDelete('set null');
31 | });
32 | }
33 |
34 | /**
35 | * Reverse the migrations.
36 | *
37 | * @return void
38 | */
39 | public function down()
40 | {
41 | Schema::dropIfExists('equipamentos');
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/database/migrations/2018_09_25_161702_create_roles_table.php:
--------------------------------------------------------------------------------
1 | increments('id');
18 | $table->timestamps();
19 | $table->string('nome');
20 | $table->boolean('grupoadmin')->default(false);
21 | });
22 | }
23 |
24 | /**
25 | * Reverse the migrations.
26 | *
27 | * @return void
28 | */
29 | public function down()
30 | {
31 | Schema::dropIfExists('roles');
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/database/migrations/2018_09_25_161829_create_role_user_table.php:
--------------------------------------------------------------------------------
1 | increments('id');
18 | $table->timestamps();
19 | $table->integer('role_id')->unsigned();
20 | $table->integer('user_id')->unsigned();
21 | });
22 | }
23 |
24 | /**
25 | * Reverse the migrations.
26 | *
27 | * @return void
28 | */
29 | public function down()
30 | {
31 | Schema::dropIfExists('role_user');
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/database/migrations/2018_09_25_202335_create_role_rede_table.php:
--------------------------------------------------------------------------------
1 | increments('id');
18 | $table->timestamps();
19 | $table->integer('role_id')->unsigned();
20 | $table->integer('rede_id')->unsigned();
21 | });
22 | }
23 |
24 | /**
25 | * Reverse the migrations.
26 | *
27 | * @return void
28 | */
29 | public function down()
30 | {
31 | Schema::dropIfExists('role_rede');
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/database/migrations/2018_10_03_174951_nullable_fields_rede.php:
--------------------------------------------------------------------------------
1 | string('dns')->nullable()->change();
18 | });
19 | }
20 |
21 | /**
22 | * Reverse the migrations.
23 | *
24 | * @return void
25 | */
26 | public function down()
27 | {
28 | Schema::table('redes', function (Blueprint $table) {
29 | //
30 | });
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/database/migrations/2018_10_04_141540_create_configs_table.php:
--------------------------------------------------------------------------------
1 | increments('id');
18 | $table->timestamps();
19 | $table->text('key');
20 | $table->longText('value')->nullable();
21 | });
22 | }
23 |
24 | /**
25 | * Reverse the migrations.
26 | *
27 | * @return void
28 | */
29 | public function down()
30 | {
31 | Schema::dropIfExists('configs');
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/database/migrations/2019_04_08_155236_rename_username_senhaunica_column.php:
--------------------------------------------------------------------------------
1 | renameColumn('username_senhaunica', 'username');
18 | $table->dropColumn('username_ldap');
19 | });
20 | }
21 |
22 | /**
23 | * Reverse the migrations.
24 | *
25 | * @return void
26 | */
27 | public function down()
28 | {
29 | Schema::table('users', function(Blueprint $table) {
30 | $table->renameColumn('username', 'username_senhaunica');
31 | $table->string('username_ldap')->nullable();
32 | });
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/database/migrations/2019_05_29_222847_remove_last_modify_by_from_redes.php:
--------------------------------------------------------------------------------
1 | dropForeign(['last_modify_by']);
18 | $table->dropColumn('last_modify_by');
19 | });
20 | }
21 |
22 | /**
23 | * Reverse the migrations.
24 | *
25 | * @return void
26 | */
27 | public function down()
28 | {
29 | Schema::table('redes', function (Blueprint $table) {
30 | //
31 | });
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/database/migrations/2019_05_29_224725_create_redes_changes.php:
--------------------------------------------------------------------------------
1 | timestamp('when')->useCurrent = true;
18 | $table->integer('rede_id')->unsigned();
19 | $table->integer('user_id')->unsigned();
20 | });
21 | }
22 |
23 | /**
24 | * Reverse the migrations.
25 | *
26 | * @return void
27 | */
28 | public function down()
29 | {
30 | //
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/database/migrations/2019_05_30_145753_create_equipamentos_changes.php:
--------------------------------------------------------------------------------
1 | timestamp('when')->useCurrent = true;
18 | $table->integer('equipamento_id')->unsigned();
19 | $table->integer('user_id')->unsigned();
20 | });
21 | }
22 |
23 | /**
24 | * Reverse the migrations.
25 | *
26 | * @return void
27 | */
28 | public function down()
29 | {
30 | //
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/database/migrations/2019_10_27_185832_add_unknown_clients.php:
--------------------------------------------------------------------------------
1 | boolean('unknown_clients')->default(0)->nullable();
19 | });
20 | \DB::statement('UPDATE redes SET unknown_clients=0;');
21 | }
22 |
23 | /**
24 | * Reverse the migrations.
25 | *
26 | * @return void
27 | */
28 | public function down()
29 | {
30 | Schema::table('redes', function (Blueprint $table) {
31 | //
32 | });
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/database/migrations/2019_10_31_122019_drop_unknown_clients.php:
--------------------------------------------------------------------------------
1 | dropColumn('unknown_clients');
18 | });
19 | }
20 |
21 | /**
22 | * Reverse the migrations.
23 | *
24 | * @return void
25 | */
26 | public function down()
27 | {
28 | Schema::table('redes', function (Blueprint $table) {
29 | //
30 | });
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/database/migrations/2019_10_31_122118_add_dhcpd_subnet_options.php:
--------------------------------------------------------------------------------
1 | text('dhcpd_subnet_options')->nullable();
18 | });
19 | \DB::statement("UPDATE redes SET dhcpd_subnet_options='deny unknown-clients;';");
20 | }
21 |
22 | /**
23 | * Reverse the migrations.
24 | *
25 | * @return void
26 | */
27 | public function down()
28 | {
29 | Schema::table('redes', function (Blueprint $table) {
30 | //
31 | });
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/database/migrations/2019_11_01_014221_add_shared.php:
--------------------------------------------------------------------------------
1 | string('shared_network')->nullable();
18 | });
19 | \DB::statement("UPDATE redes SET shared_network='default';");
20 | }
21 |
22 | /**
23 | * Reverse the migrations.
24 | *
25 | * @return void
26 | */
27 | public function down()
28 | {
29 | Schema::table('redes', function (Blueprint $table) {
30 | //
31 | });
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/database/migrations/2020_11_17_181030_change_columns_in_equipamentos.php:
--------------------------------------------------------------------------------
1 | dropColumn('naopatrimoniado');
18 | $table->dropColumn('fixarip');
19 | $table->renameColumn('descricaosempatrimonio', 'descricao');
20 | });
21 | }
22 |
23 | /**
24 | * Reverse the migrations.
25 | *
26 | * @return void
27 | */
28 | public function down()
29 | {
30 | Schema::table('equipamentos', function (Blueprint $table) {
31 | //
32 | });
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/database/migrations/2021_02_25_020004_new_columns_redes_table.php:
--------------------------------------------------------------------------------
1 | boolean('active_dhcp')->default(1)->nullable();
19 | $table->boolean('active_freeradius')->default(1)->nullable();
20 | });
21 | \DB::statement('UPDATE redes SET active_dhcp=1;');
22 | \DB::statement('UPDATE redes SET active_freeradius=1;');
23 | }
24 |
25 | /**
26 | * Reverse the migrations.
27 | *
28 | * @return void
29 | */
30 | public function down()
31 | {
32 | Schema::table('redes', function (Blueprint $table) {
33 | //
34 | });
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/database/migrations/2021_03_25_215743_change_column_descricao_equipamentos_table.php:
--------------------------------------------------------------------------------
1 | text('descricao')->nullable()->change();
18 | });
19 | }
20 |
21 | /**
22 | * Reverse the migrations.
23 | *
24 | * @return void
25 | */
26 | public function down()
27 | {
28 | Schema::table('equipamentos', function (Blueprint $table) {
29 | //
30 | });
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/database/migrations/2021_04_01_033039_create_audits_table.php:
--------------------------------------------------------------------------------
1 | bigIncrements('id');
18 | $table->string('user_type')->nullable();
19 | $table->unsignedBigInteger('user_id')->nullable();
20 | $table->string('event');
21 | $table->morphs('auditable');
22 | $table->text('old_values')->nullable();
23 | $table->text('new_values')->nullable();
24 | $table->text('url')->nullable();
25 | $table->ipAddress('ip_address')->nullable();
26 | $table->string('user_agent', 1023)->nullable();
27 | $table->string('tags')->nullable();
28 | $table->timestamps();
29 |
30 | $table->index(['user_id', 'user_type']);
31 | });
32 | }
33 |
34 | /**
35 | * Reverse the migrations.
36 | *
37 | * @return void
38 | */
39 | public function down()
40 | {
41 | Schema::drop('audits');
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/database/migrations/2021_04_01_041328_drop_equipamentos_changes_table.php:
--------------------------------------------------------------------------------
1 | increments('id');
18 | $table->timestamps();
19 | $table->string('original_name');
20 | $table->string('path');
21 | $table->string('mimetype');
22 | $table->integer('equipamento_id')->unsigned()->nullable();
23 | $table->foreign('equipamento_id')->references('id')->on('equipamentos')->onDelete('set null');
24 | $table->integer('user_id')->unsigned()->nullable();
25 | $table->foreign('user_id')->references('id')->on('users')->onDelete('set null');
26 | });
27 | }
28 |
29 | /**
30 | * Reverse the migrations.
31 | *
32 | * @return void
33 | */
34 | public function down()
35 | {
36 | Schema::dropIfExists('files');
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/database/seeders/ConfigsTableSeeder.php:
--------------------------------------------------------------------------------
1 | insert([
18 | 'created_at' => '2020-07-03 14:40:53',
19 | 'updated_at' => '2020-07-03 14:40:53',
20 | 'key' => 'dhcp_global',
21 | 'value' => 'ddns-update-style none;
22 | default-lease-time 86400;
23 | max-lease-time 86400;
24 | authoritative;',
25 | ]);
26 | DB::table('configs')->insert([
27 | 'created_at' => '2020-07-03 14:40:53',
28 | 'updated_at' => '2020-07-03 14:40:53',
29 | 'key' => 'shared_network',
30 | 'value' => 'pro-aluno',
31 | ]);
32 | DB::table('configs')->insert([
33 | 'created_at' => '2020-07-03 14:40:53',
34 | 'updated_at' => '2020-07-03 14:40:53',
35 | 'key' => 'unique_iprede',
36 | 'value' => '190.0.0.0',
37 | ]);
38 | DB::table('configs')->insert([
39 | 'created_at' => '2020-07-03 14:40:53',
40 | 'updated_at' => '2020-07-03 14:40:53',
41 | 'key' => 'unique_gateway',
42 | 'value' => '190.0.0.1',
43 | ]);
44 | DB::table('configs')->insert([
45 | 'created_at' => '2020-07-03 14:40:53',
46 | 'updated_at' => '2020-07-03 14:40:53',
47 | 'key' => 'unique_cidr',
48 | 'value' => '24',
49 | ]);
50 | DB::table('configs')->insert([
51 | 'created_at' => '2020-07-03 14:40:53',
52 | 'updated_at' => '2020-07-03 14:40:53',
53 | 'key' => 'ips_reservados',
54 | 'value' => '190.0.0.10',
55 | ]);
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/database/seeders/DatabaseSeeder.php:
--------------------------------------------------------------------------------
1 | call([
17 | UsersTableSeeder::class,
18 | RolesTableSeeder::class,
19 | RedesTableSeeder::class,
20 | EquipamentosTableSeeder::class,
21 | ConfigsTableSeeder::class,
22 | ]);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/database/seeders/EquipamentosTableSeeder.php:
--------------------------------------------------------------------------------
1 | null,
18 | 'descricao' => 'Computador do Prof. Joel',
19 | 'macaddress' => '01:55:44:88:78:77',
20 | 'local' => 'Sala 10',
21 | 'vencimento' => '25/11/2022',
22 | 'ip' => '192.168.0.10',
23 | 'rede_id' => '16',
24 | 'user_id' => '1',
25 | ];
26 | Equipamento::create($entrada);
27 | Equipamento::factory(20)->create();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/database/seeders/FileSeeder.php:
--------------------------------------------------------------------------------
1 | 'Departamento de Música Clássica',
18 | 'iprede' => '192.168.0.0',
19 | 'gateway' => '192.168.0.1',
20 | 'dns' => '192.168.0.10',
21 | 'ntp' => '192.168.0.11',
22 | 'netbios' => '192.168.0.12',
23 | 'cidr' => '22',
24 | 'vlan' => '1587',
25 | 'ad_domain' => 'musica.usp.br',
26 | 'user_id' => '1',
27 | 'shared_network' => 'default',
28 | ];
29 | Rede::create($entrada);
30 |
31 | #Rede::factory(10)->create();
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/database/seeders/RolesTableSeeder.php:
--------------------------------------------------------------------------------
1 | 'Escola de Música',
21 | ];
22 | Role::create($entrada);
23 |
24 | Role::factory(5)->create()->each(function ($role) {
25 | $users = User::factory(5)->make();
26 | $role->users()->saveMany($users);
27 |
28 | $redes = Rede::factory(3)->make();
29 | $role->redes()->saveMany($redes);
30 | });
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/database/seeders/UsersTableSeeder.php:
--------------------------------------------------------------------------------
1 | 'Fulano da Silva',
18 | 'email' => 'fulano.silva@brasil.com',
19 | 'password' => bcrypt('secret'), // hash para 'secret'
20 | 'username' => 'fulano',
21 | ];
22 | User::create($entrada);
23 |
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "private": true,
3 | "scripts": {
4 | "dev": "npm run development",
5 | "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
6 | "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
7 | "watch-poll": "npm run watch -- --watch-poll",
8 | "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
9 | "prod": "npm run production",
10 | "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
11 | },
12 | "devDependencies": {
13 | "axios": "^0.19",
14 | "bootstrap-sass": "^3.3.7",
15 | "cross-env": "^5.1",
16 | "jquery": "^3.2",
17 | "laravel-mix": "^2.1.14",
18 | "lodash": "^4.17.4",
19 | "vue": "^2.5.7"
20 | },
21 | "dependencies": {
22 | "ajv": "^6.5.3",
23 | "imagemin": "^5.3.1",
24 | "img-loader": "^3.0.0",
25 | "open-iconic": "^1.1.1"
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/phpunit.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 | ./tests/Unit
10 |
11 |
12 | ./tests/Feature
13 |
14 |
15 |
16 |
17 | ./app
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/public/.htaccess:
--------------------------------------------------------------------------------
1 |
2 |
3 | Options -MultiViews -Indexes
4 |
5 |
6 | RewriteEngine On
7 |
8 | # Handle Authorization Header
9 | RewriteCond %{HTTP:Authorization} .
10 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
11 |
12 | # Redirect Trailing Slashes If Not A Folder...
13 | RewriteCond %{REQUEST_FILENAME} !-d
14 | RewriteCond %{REQUEST_URI} (.+)/$
15 | RewriteRule ^ %1 [L,R=301]
16 |
17 | # Handle Front Controller...
18 | RewriteCond %{REQUEST_FILENAME} !-d
19 | RewriteCond %{REQUEST_FILENAME} !-f
20 | RewriteRule ^ index.php [L]
21 |
22 |
--------------------------------------------------------------------------------
/public/assets/css/copaco.css:
--------------------------------------------------------------------------------
1 | body {
2 | font-size: 17px;
3 | }
4 |
5 | .arquivo-img{
6 | max-height: 100px;
7 | }
--------------------------------------------------------------------------------
/public/assets/js/copaco.js:
--------------------------------------------------------------------------------
1 | $('.datepicker').datepicker({
2 | format: 'dd/mm/yyyy',
3 | language: 'pt-BR',
4 | startDate: 'today',
5 | autoclose: true,
6 | todayHighlight: true
7 | });
8 |
9 |
10 | var macAddress = document.getElementById("macaddress");
11 |
12 | function formatMAC(e) {
13 | var r = /([a-f0-9]{2})([a-f0-9]{2})/i,
14 | str = e.target.value.replace(/[^a-f0-9]/ig, "");
15 | str = str.toUpperCase();
16 |
17 | while (r.test(str)) {
18 | str = str.replace(r, '$1' + ':' + '$2');
19 | }
20 |
21 | e.target.value = str.slice(0, 17);
22 | };
23 |
24 | macAddress.addEventListener("keyup", formatMAC, false);
25 |
26 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uspdev/copaco/138181bf2f6cc5256573af3a19f0f4776ad4337c/public/favicon.ico
--------------------------------------------------------------------------------
/public/index.php:
--------------------------------------------------------------------------------
1 | make(Kernel::class);
50 |
51 | $response = tap($kernel->handle(
52 | $request = Request::capture()
53 | ))->send();
54 |
55 | $kernel->terminate($request, $response);
56 |
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | User-agent: *
2 | Disallow:
3 |
--------------------------------------------------------------------------------
/public/web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | 
2 | 
3 |
4 | 
5 | 
6 |
7 | # Sistema de COntrole de PArque COmputacional
8 |
9 | Sistema desenvolvido em Laravel e tem por objetivo tornar a gerência dos equipamentos que navegam em sua rede mais eficiente e prática.
10 |
11 | Funcionalidades:
12 |
13 | - Cadastro de equipamentos com MAC Address
14 | - Cadastro de redes
15 | - Atribuição automática de IPs livres
16 | - Geração de `dhcpd.conf` com suporte a multi redes/subredes
17 | - Geração de `dhcpd.conf` com uma única subrede
18 | - Geração de configuração para servidores freeradius, tanto por arquivo, quanto por banco de dados,
19 | no contexto do mac-authentication, isto é, entrega de vlan correspondente ao MACaddress
20 |
21 | ## Instalação de bibliotecas e dependências
22 |
23 | php7+
24 | php-bcmath
25 | php-ldap
26 | php-curl
27 |
28 | ## Procedimentos de deploy
29 |
30 | Em seu terminal:
31 |
32 | ```
33 | composer install
34 | cp .env.example .env
35 | ```
36 |
37 | Editar o arquivo `.env`
38 |
39 | - Dados da conexão
40 | - Dados do OAuth e números USP dos admins do sistema
41 |
42 | ```
43 | SENHAUNICA_KEY=
44 | SENHAUNICA_SECRET=
45 | SENHAUNICA_CALLBACK_ID=
46 | ```
47 |
48 | Rode as migrations
49 |
50 | ```
51 | php artisan key:generate
52 | php artisan migrate
53 | ```
54 |
55 | Caso falte alguma dependência, siga as instruções do `composer`.
56 |
57 | # Usuários
58 |
59 | O sistema trabalha tanto com usuário local, quanto integrado a bilbioteca de senha única da USP.
60 | Configurar os usernames do *SUPERADMINS*, isto é, pessoes que terão permissão total no sistema:
61 |
62 | SUPERADMINS_USERNAMES=14234,zezinho,9876663
63 |
64 | O auto-cadastro de usuários com login local é permitido via um código de autorização
65 | que você deve infomar para as pessoas que poderão fazer esse autocadastro:
66 |
67 | CODIGO_ACESSO='MEU-CODIGO-SECRETO'
68 |
69 | Se quiser usar apenas senha única e desativar o cadastro de login local:
70 |
71 | SOMENTE_SENHAUNICA=true
72 |
73 | ## Publicando Assets
74 |
75 | Para ter a front disponível utilize o comando:
76 |
77 | php artisan deploy:assets
78 |
79 | ## FreeRadius
80 |
81 | Se for usar o Freeradius, criar um segundo banco de dados com o [esquema](https://github.com/FreeRADIUS/freeradius-server/blob/master/raddb/mods-config/sql/main/mysql/schema.sql) e setar as variáveis no .env:
82 |
83 | FREERADIUS_HABILITAR=True
84 | FREERADIUS_HOST=localhost
85 | FREERADIUS_USER=freeradius
86 | FREERADIUS_DB=freeradius
87 | FREERADIUS_PASSWD=freeradius
88 | FREERADIUS_MACADDR_SEPARATOR='-'
89 | FREERADIUS_MACADDR_CASE=lower
90 |
91 | ## Seeders que podem ajudar na produção de dados aleatórios:
92 |
93 | php artisan migrate:fresh --seed
94 |
95 | ## Testes TDD
96 |
97 | ./vendor/bin/phpunit
98 |
99 | # Geração de arquivos para servidor dhcp e freeradius
100 |
101 | Crie uma chave no .env para autorizar as requisições:
102 |
103 | CONSUMER_DEPLOY_KEY=d34dhd892nfAzt1OMC0x
104 |
105 | Exemplo de como consumir um dhcpd.conf:
106 |
107 | curl -s -d "consumer_deploy_key=d34dhd892nfAzt1OMC0x" -X POST http://localhost:8000/api/dhcpd.conf
108 | curl -s -d "consumer_deploy_key=d34dhd892nfAzt1OMC0x" -X POST http://localhost:8000/api/uniquedhcpd.conf
109 |
110 | Exemplo de como consumir um *mods-config/files/authorize* para freeradius:
111 |
112 | curl -s -d "consumer_deploy_key=d34dhd892nfAzt1OMC0x" -X POST http://localhost:8000/api/freeradius/authorize_file
113 |
114 | ## Contribuindo com o projeto
115 |
116 | ### Passos iniciais
117 |
118 | Siga o guia no site do [uspdev](https://uspdev.github.io/contribua)
119 |
120 | ### Padrões de Projeto
121 |
122 | Utilizamos a [PSR-2](https://www.php-fig.org/psr/psr-2/) para padrões de projeto. Ajuste seu editor favorito para a especificação.
123 |
--------------------------------------------------------------------------------
/resources/assets/js/bootstrap.js:
--------------------------------------------------------------------------------
1 |
2 | window._ = require('lodash');
3 |
4 | /**
5 | * We'll load jQuery and the Bootstrap jQuery plugin which provides support
6 | * for JavaScript based Bootstrap features such as modals and tabs. This
7 | * code may be modified to fit the specific needs of your application.
8 | */
9 |
10 | try {
11 | window.$ = window.jQuery = require('jquery');
12 |
13 | require('bootstrap-sass');
14 | } catch (e) {}
15 |
16 | /**
17 | * We'll load the axios HTTP library which allows us to easily issue requests
18 | * to our Laravel back-end. This library automatically handles sending the
19 | * CSRF token as a header based on the value of the "XSRF" token cookie.
20 | */
21 |
22 | window.axios = require('axios');
23 |
24 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
25 |
26 | /**
27 | * Next we will register the CSRF Token as a common header with Axios so that
28 | * all outgoing HTTP requests automatically have it attached. This is just
29 | * a simple convenience so we don't have to attach every token manually.
30 | */
31 |
32 | let token = document.head.querySelector('meta[name="csrf-token"]');
33 |
34 | if (token) {
35 | window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
36 | } else {
37 | console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
38 | }
39 |
40 | /**
41 | * Echo exposes an expressive API for subscribing to channels and listening
42 | * for events that are broadcast by Laravel. Echo and event broadcasting
43 | * allows your team to easily build robust real-time web applications.
44 | */
45 |
46 | // import Echo from 'laravel-echo'
47 |
48 | // window.Pusher = require('pusher-js');
49 |
50 | // window.Echo = new Echo({
51 | // broadcaster: 'pusher',
52 | // key: 'your-pusher-key',
53 | // cluster: 'mt1',
54 | // encrypted: true
55 | // });
56 |
--------------------------------------------------------------------------------
/resources/assets/js/components/ExampleComponent.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
Example Component
7 |
8 |
9 | I'm an example component!
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
24 |
--------------------------------------------------------------------------------
/resources/assets/sass/_variables.scss:
--------------------------------------------------------------------------------
1 |
2 | // Body
3 | $body-bg: #f5f8fa;
4 |
5 | // Borders
6 | $laravel-border-color: darken($body-bg, 10%);
7 | $list-group-border: $laravel-border-color;
8 | $navbar-default-border: $laravel-border-color;
9 | $panel-default-border: $laravel-border-color;
10 | $panel-inner-border: $laravel-border-color;
11 |
12 | // Brands
13 | $brand-primary: #3097D1;
14 | $brand-info: #8eb4cb;
15 | $brand-success: #2ab27b;
16 | $brand-warning: #cbb956;
17 | $brand-danger: #bf5329;
18 |
19 | // Typography
20 | $icon-font-path: "~bootstrap-sass/assets/fonts/bootstrap/";
21 | $font-family-sans-serif: "Raleway", sans-serif;
22 | $font-size-base: 14px;
23 | $line-height-base: 1.6;
24 | $text-color: #636b6f;
25 |
26 | // Navbar
27 | $navbar-default-bg: #fff;
28 |
29 | // Buttons
30 | $btn-default-color: $text-color;
31 |
32 | // Inputs
33 | $input-border: lighten($text-color, 40%);
34 | $input-border-focus: lighten($brand-primary, 25%);
35 | $input-color-placeholder: lighten($text-color, 30%);
36 |
37 | // Panels
38 | $panel-default-heading-bg: #fff;
39 |
--------------------------------------------------------------------------------
/resources/assets/sass/app.scss:
--------------------------------------------------------------------------------
1 |
2 | // Fonts
3 | @import '~open-iconic/font/css/open-iconic-bootstrap';
4 | // @import url("https://fonts.googleapis.com/css?family=Raleway:300,400,600");
5 |
6 | // Variables
7 | @import "variables";
8 |
9 | // Bootstrap
10 | @import "~bootstrap-sass/assets/stylesheets/bootstrap";
11 |
--------------------------------------------------------------------------------
/resources/assets/sass/dashboard.scss:
--------------------------------------------------------------------------------
1 | body {
2 | font-size: .875rem;
3 | }
4 |
5 | .feather {
6 | width: 16px;
7 | height: 16px;
8 | vertical-align: text-bottom;
9 | }
10 |
11 | /*
12 | * Sidebar
13 | */
14 |
15 | .sidebar {
16 | position: fixed;
17 | /* top: 0;*/
18 | bottom: 0;
19 | left: 0;
20 | z-index: 100; /* Behind the navbar */
21 | padding: 0;
22 | box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);
23 | }
24 |
25 | .sidebar-sticky {
26 | position: -webkit-sticky;
27 | position: sticky;
28 | top: 48px; /* Height of navbar */
29 | height: calc(100vh - 48px);
30 | padding-top: .5rem;
31 | overflow-x: hidden;
32 | overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */
33 | }
34 |
35 | .sidebar .nav-link {
36 | font-weight: 500;
37 | color: #333;
38 | }
39 |
40 | .sidebar .nav-link .feather {
41 | margin-right: 4px;
42 | color: #999;
43 | }
44 |
45 | .sidebar .nav-link.active {
46 | color: #007bff;
47 | }
48 |
49 | .sidebar .nav-link:hover .feather,
50 | .sidebar .nav-link.active .feather {
51 | color: inherit;
52 | }
53 |
54 | .sidebar-heading {
55 | font-size: .75rem;
56 | text-transform: uppercase;
57 | }
58 |
59 | /*
60 | * Navbar
61 | */
62 |
63 | .navbar-brand {
64 | padding-top: .75rem;
65 | padding-bottom: .75rem;
66 | font-size: 1rem;
67 | background-color: rgba(0, 0, 0, .25);
68 | box-shadow: inset -1px 0 0 rgba(0, 0, 0, .25);
69 | }
70 |
71 | .navbar .form-control {
72 | padding: .75rem 1rem;
73 | border-width: 0;
74 | border-radius: 0;
75 | }
76 |
77 | .form-control-dark {
78 | color: #fff;
79 | background-color: rgba(255, 255, 255, .1);
80 | border-color: rgba(255, 255, 255, .1);
81 | }
82 |
83 | .form-control-dark:focus {
84 | border-color: transparent;
85 | box-shadow: 0 0 0 3px rgba(255, 255, 255, .25);
86 | }
87 |
88 | /*
89 | * Utilities
90 | */
91 |
92 | .border-top { border-top: 1px solid #e5e5e5; }
93 | .border-bottom { border-bottom: 1px solid #e5e5e5; }
94 |
--------------------------------------------------------------------------------
/resources/lang/en/auth.php:
--------------------------------------------------------------------------------
1 | 'These credentials do not match our records.',
17 | 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
18 |
19 | ];
20 |
--------------------------------------------------------------------------------
/resources/lang/en/pagination.php:
--------------------------------------------------------------------------------
1 | '« Previous',
17 | 'next' => 'Next »',
18 |
19 | ];
20 |
--------------------------------------------------------------------------------
/resources/lang/en/passwords.php:
--------------------------------------------------------------------------------
1 | 'Passwords must be at least six characters and match the confirmation.',
17 | 'reset' => 'Your password has been reset!',
18 | 'sent' => 'We have e-mailed your password reset link!',
19 | 'token' => 'This password reset token is invalid.',
20 | 'user' => "We can't find a user with that e-mail address.",
21 |
22 | ];
23 |
--------------------------------------------------------------------------------
/resources/views/auth/login.blade.php:
--------------------------------------------------------------------------------
1 | @extends('master')
2 |
3 | @section('content')
4 |
5 | @if (config('copaco.somente_senhaunica'))
6 |
9 | @endif
10 |
11 |
71 | @endsection
72 |
--------------------------------------------------------------------------------
/resources/views/auth/passwords/email.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.app')
2 |
3 | @section('content')
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | @if (session('status'))
12 |
13 | {{ session('status') }}
14 |
15 | @endif
16 |
17 |
42 |
43 |
44 |
45 |
46 |
47 | @endsection
48 |
--------------------------------------------------------------------------------
/resources/views/auth/passwords/reset.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.app')
2 |
3 | @section('content')
4 |
65 | @endsection
66 |
--------------------------------------------------------------------------------
/resources/views/config/index.blade.php:
--------------------------------------------------------------------------------
1 | @extends('master')
2 |
3 | @section('content_header')
4 | Configurações
5 | @stop
6 |
7 | @section('content')
8 |
9 |
14 |
15 |
16 |
17 |
18 |
19 |
24 |
25 |
26 |
27 |
28 |
29 |
33 |
34 |
35 |
36 |
37 |
38 |
43 |
44 |
45 |
62 |
63 | @stop
64 |
--------------------------------------------------------------------------------
/resources/views/config/partials/dhcp.blade.php:
--------------------------------------------------------------------------------
1 |
37 |
--------------------------------------------------------------------------------
/resources/views/config/partials/dhcp_sem_subnets.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Essa é uma configuração extra caso seja necessário subir um servidor dhcp de emergência com todos
6 | Mac-Address cadastrados nesse sistema em um rede especifíca definida aqui. Neste caso todos IPs
7 | alocados para cada Mac-Address no sistema serão ignorados e o sistema definirá aleatóriamente IPs.
8 | Foi criar essa opção para depuração e para possíveis situações de desastre.
9 |
10 |
11 |
45 |
56 |
Caso queira também gerar um dhcpd.conf sem segmentação de rede
57 | preencha os dados dessa única rede
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/resources/views/equipamentos/create.blade.php:
--------------------------------------------------------------------------------
1 | @extends('master')
2 |
3 | @section('content_header')
4 | Cadastrar Equipamento
5 | @stop
6 |
7 | @section('content')
8 |
9 |
18 | @stop
19 |
--------------------------------------------------------------------------------
/resources/views/equipamentos/edit.blade.php:
--------------------------------------------------------------------------------
1 | @extends('master')
2 |
3 | @section('content_header')
4 | Editar Equipamento
5 | @stop
6 |
7 | @section('content')
8 |
9 |
19 |
20 | @endsection
21 |
22 |
--------------------------------------------------------------------------------
/resources/views/equipamentos/files/partials/form.blade.php:
--------------------------------------------------------------------------------
1 |
15 |
--------------------------------------------------------------------------------
/resources/views/equipamentos/form.blade.php:
--------------------------------------------------------------------------------
1 |
19 |
20 |
28 |
29 |
58 |
59 |
67 |
68 | Enviar
69 |
70 |
--------------------------------------------------------------------------------
/resources/views/equipamentos/partials/files.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | @can('equipamentos.update', $equipamento)
5 | @include('equipamentos.files.partials.form')
6 | @endcan
7 |
8 |
9 |
10 |
11 |
12 | Nome do Arquivo
13 | Data de Envio
14 | Ações
15 |
16 |
17 |
18 | @foreach ($equipamento->files as $file)
19 |
20 | @if(preg_match('/jpeg|png/i', $file->mimetype))
21 |
22 |
23 |
26 |
27 |
28 | @else
29 | {{ $file->original_name }}
30 | @endif
31 |
32 | {{ Carbon\Carbon::parse($file->created_at)->format('d/m/Y') }}
33 |
34 | @can('equipamentos.delete', $equipamento)
35 |
36 |
41 |
42 | @endcan
43 |
44 | @endforeach
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/resources/views/equipamentos/show.blade.php:
--------------------------------------------------------------------------------
1 | @extends('master')
2 |
3 | @section('styles')
4 | @parent
5 |
6 | @endsection
7 |
8 |
9 | @section('content_header')
10 | Equipamento: {{ $equipamento->macaddress }}
11 | @stop
12 |
13 | @section('content')
14 |
15 |
16 |
17 |
18 |
19 |
20 | Patrimônio: {{$equipamento->patrimonio}}
21 | Mac Address: {{ $equipamento->macaddress }}
22 | Local: {{ $equipamento->local }}
23 | Vencimento: {{ $equipamento->vencimento }}
24 | Rede: {{ $equipamento->rede->nome ?? '' }}
25 | IP: {{ $equipamento->ip ?? '' }}
26 | Responsável : {{ $equipamento->user->name }}
27 | Descrição: {!! nl2br($equipamento->descricao) !!}
28 |
29 |
30 | @include('equipamentos.partials.files')
31 |
32 |
33 |
34 |
52 |
53 |
54 | Histórico
55 |
56 | @include('partials.audit.index', ['model' => $equipamento])
57 |
58 |
59 | @stop
60 |
61 | @section('javascripts_bottom')
62 | @parent
63 |
64 | @endsection
--------------------------------------------------------------------------------
/resources/views/index.blade.php:
--------------------------------------------------------------------------------
1 | @extends('master')
2 |
3 | @section('content_header')
4 | Sistema COntrole do PArque COmputacional
5 | @stop
6 |
7 | @section('content')
8 | @auth
9 |
10 |
15 |
16 |
17 |
Meus grupos:
18 |
19 |
20 | @forelse (Auth::user()->roles()->get() as $role)
21 | {{ $role->nome }}
22 | @empty
23 | Não está em nenhum grupo
24 | @endforelse
25 |
26 |
27 |
28 |
29 |
30 | @else
31 | Você ainda não fez seu login !
32 | @endauth
33 |
34 | @stop
35 |
--------------------------------------------------------------------------------
/resources/views/master.blade.php:
--------------------------------------------------------------------------------
1 | @extends('laravel-usp-theme::master')
2 |
3 | @section('title', 'COPACO')
4 |
5 | @section('flash')
6 |
7 | @include('messages.flash')
8 | @include('messages.errors')
9 |
10 | @stop
11 |
12 | @section('styles')
13 | @parent
14 |
15 |
16 |
17 |
18 | @stop
19 |
20 | @section('javascripts_bottom')
21 | @parent
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
36 |
37 | @stop
38 |
--------------------------------------------------------------------------------
/resources/views/messages/errors.blade.php:
--------------------------------------------------------------------------------
1 | @if ($errors->any())
2 |
3 |
4 | @foreach ($errors->all() as $error)
5 | {{ $error }}
6 | @endforeach
7 |
8 |
9 | @endif
10 |
--------------------------------------------------------------------------------
/resources/views/messages/flash.blade.php:
--------------------------------------------------------------------------------
1 |
2 | @foreach (['danger', 'warning', 'success', 'info'] as $msg)
3 | @if(Session::has('alert-' . $msg))
4 |
5 |
{{ Session::get('alert-' . $msg) }}
6 | ×
7 |
8 | @endif
9 | @endforeach
10 |
--------------------------------------------------------------------------------
/resources/views/partials/audit/index.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Data
5 | Usuário(a)
6 | Mudanças
7 |
8 |
9 |
10 | @foreach($model->audits as $audit)
11 |
12 | {{ \Carbon\Carbon::parse($audit->getMetadata()['audit_created_at'])->format('d/m/Y H:i') }}
13 | {{ $audit->getMetadata()['user_name'] }}
14 |
15 | @foreach($audit->getModified() as $field=>$modified)
16 | {{$field}}: {{ $modified['old'] ?? '' }} -> {{ $modified['new'] }}
17 | @endforeach
18 |
19 |
20 | @endforeach
21 |
22 |
--------------------------------------------------------------------------------
/resources/views/redes/create.blade.php:
--------------------------------------------------------------------------------
1 | @extends('master')
2 |
3 | @section('content_header')
4 | Cadastrar Rede
5 | @stop
6 |
7 | @section('content')
8 | @include('messages.flash')
9 | @include('messages.errors')
10 |
11 |
20 |
21 | @stop
22 |
--------------------------------------------------------------------------------
/resources/views/redes/edit.blade.php:
--------------------------------------------------------------------------------
1 | @extends('master')
2 |
3 | @section('content_header')
4 | Editar Rede
5 | @stop
6 |
7 |
8 | @section('content')
9 |
10 | @include('messages.flash')
11 | @include('messages.errors')
12 |
13 |
23 |
24 | @stop
25 |
--------------------------------------------------------------------------------
/resources/views/redes/index.blade.php:
--------------------------------------------------------------------------------
1 | @extends('master')
2 |
3 | @section('content_header')
4 | Cadastrar Rede
5 | @stop
6 |
7 | @section('content')
8 | @include('messages.flash')
9 | @include('messages.errors')
10 |
11 |
12 | Adicionar Rede
13 |
14 |
15 |
16 | Nº de Redes Cadastradas: {{$redes->count()}}
17 |
18 |
19 |
20 |
21 |
22 | Nome
23 | IP Rede
24 | VLAN
25 | Gateway
26 | Hosts
27 | Ações
28 |
29 |
30 |
31 | @foreach($redes as $rede)
32 |
33 | {{ $rede->nome }}
34 | {{ $rede->iprede }}/{{ $rede->cidr }}
35 | {{ $rede->vlan }}
36 | {{ $rede->gateway }}
37 | {{ $rede->equipamentos->count() }}
38 |
39 |
40 |
41 |
42 |
47 |
48 |
49 | @endforeach
50 |
51 |
52 |
53 |
54 | @stop
55 |
--------------------------------------------------------------------------------
/resources/views/redes/migrate.blade.php:
--------------------------------------------------------------------------------
1 | @extends('master')
2 |
3 | @section('content_header')
4 | Cadastrar Rede
5 | @stop
6 |
7 | @section('content')
8 | @include('messages.flash')
9 | @include('messages.errors')
10 |
11 |
50 |
51 | @stop
52 |
--------------------------------------------------------------------------------
/resources/views/redes/show.blade.php:
--------------------------------------------------------------------------------
1 | @extends('master')
2 |
3 | @section('content_header')
4 | Rede: {{ $rede->nome }}
5 | @stop
6 |
7 | @section('content')
8 |
9 | Nome da Rede: {{$rede->nome}}
10 |
13 |
14 |
15 |
16 |
17 |
18 | Rede : {{ $rede->iprede }}/{{ $rede->cidr }}
19 | Gateway : {{ $rede->gateway }}
20 | VLAN : {{ $rede->vlan }}
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | Netbios : {{ $rede->netbios }}
30 | NTP : {{ $rede->ntp }}
31 | DNS : {{ $rede->dns }}
32 | Domain Active Directory : {{ $rede->ad_domain }}
33 | Opções dhcp da subnet: : {{ $rede->dhcpd_subnet_options }}
34 | shared_network : {{ $rede->shared_network }}
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 | Responsável : {{ $rede->user->name }}
44 | Grupos com permissão nessa rede:
45 |
46 | @foreach ( $rede->roles()->get() as $role)
47 | {{ $role->nome }}
48 | @endforeach
49 |
50 |
51 |
52 |
53 |
54 |
55 | Equipamentos alocados nesta rede:
56 |
57 |
58 |
59 |
60 | MacAddress
61 | IP
62 | Patrimônio
63 | Local
64 | Descrição
65 |
66 |
67 |
68 | @foreach($rede->equipamentos->sortBy('ip') as $equipamento)
69 |
70 | {{ $equipamento->macaddress}}
71 | {{ $equipamento->ip }}
72 | {{ $equipamento->patrimonio }}
73 | {{ $equipamento->local }}
74 | {!! nl2br($equipamento->descricao) !!}
75 |
76 | @endforeach
77 |
78 |
79 |
80 | Alterações nessa rede
81 | Histórico
82 |
83 | @include('partials.audit.index', ['model' => $rede])
84 |
85 | @stop
86 |
87 |
88 |
--------------------------------------------------------------------------------
/resources/views/roles/create.blade.php:
--------------------------------------------------------------------------------
1 | @extends('master')
2 |
3 | @section('content_header')
4 | Cadastrar Grupo
5 | @stop
6 |
7 | @section('content')
8 | @include('messages.flash')
9 | @include('messages.errors')
10 |
19 |
20 | @stop
21 |
--------------------------------------------------------------------------------
/resources/views/roles/edit.blade.php:
--------------------------------------------------------------------------------
1 | @extends('master')
2 |
3 | @section('content_header')
4 | Editar Grupo
5 | @stop
6 |
7 |
8 | @section('content')
9 | @include('messages.flash')
10 | @include('messages.errors')
11 |
21 |
22 | @stop
23 |
--------------------------------------------------------------------------------
/resources/views/roles/form.blade.php:
--------------------------------------------------------------------------------
1 |
2 | Nome
3 |
4 |
5 |
6 |
7 |
8 | @if(old('grupoadmin')=='' and isset($role->grupoadmin))
9 | grupoadmin ? 'checked' : ''}}>
10 | @else
11 |
12 | @endif
13 |
14 | Grupo administrativo?
15 | Marque essa opção caso você queira que as pessoas desse grupo
16 | vizualizem e administrem os equipamentos do mesmo.
17 |
18 |
19 |
20 |
21 |
22 | Redes do grupo {{ $role->nome ?? old('nome') }}:
23 |
24 | @foreach($redes->sortBy('nome') as $rede)
25 |
26 | @if(old('redes[]')=='' and isset($role->nome))
27 | hasRole($role->nome) ? 'checked' : ''}}> {{ $rede->nome }}
28 | @else
29 | id)? 'checked' : ''}}> {{ $rede->nome }}
30 | @endif
31 | @endforeach
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/resources/views/roles/index.blade.php:
--------------------------------------------------------------------------------
1 | @extends('master')
2 |
3 | @section('content_header')
4 | Cadastrar novo Grupo
5 | @stop
6 |
7 | @section('content')
8 | @include('messages.flash')
9 | @include('messages.errors')
10 |
11 |
12 | Adicionar Grupo
13 |
14 |
15 | Nº de Grupos Cadastrados: {{$roles->count()}}
16 |
17 |
18 |
19 |
20 |
21 | Nome
22 | Ações
23 |
24 |
25 |
26 | @foreach($roles as $role)
27 |
28 | {{ $role->nome }}
29 |
30 |
31 |
32 |
33 |
38 |
39 |
40 | @endforeach
41 |
42 |
43 |
44 | {{ $roles->appends(request()->query())->links() }}
45 | @stop
46 |
47 | @section('js')
48 |
55 | @stop
56 |
--------------------------------------------------------------------------------
/resources/views/roles/show.blade.php:
--------------------------------------------------------------------------------
1 | @extends('master')
2 |
3 | @section('content_header')
4 | Grupo:{{ $role->nome }}
5 | @stop
6 |
7 | @section('content')
8 | @include('messages.flash')
9 | @include('messages.errors')
10 |
11 |
14 |
15 |
16 |
17 |
18 |
19 | Grupo : {{ $role->nome }}
20 | Tipo :
21 | @if($role->grupoadmin)
22 | Grupo administrativo
23 | @else
24 | Grupo comum
25 | @endif
26 |
27 |
28 | Pessoas :
29 |
30 | @foreach($role->users()->get() as $user)
31 | {{ $user->name }}
32 | @endforeach
33 |
34 |
35 | Redes :
36 |
37 | @foreach($role->redes()->get() as $rede)
38 | {{ $rede->nome }}
39 | @endforeach
40 |
41 |
42 |
43 |
44 |
45 |
46 | @stop
47 |
48 |
49 |
--------------------------------------------------------------------------------
/resources/views/users/edit.blade.php:
--------------------------------------------------------------------------------
1 | @extends('master')
2 |
3 | @section('content_header')
4 |
5 | @stop
6 |
7 | @section('content')
8 | @include('messages.flash')
9 | @include('messages.errors')
10 |
20 |
21 | @endsection
22 |
23 |
--------------------------------------------------------------------------------
/resources/views/users/form.blade.php:
--------------------------------------------------------------------------------
1 |
2 | Grupos de {{ $user->name }}:
3 |
4 | @foreach($roles->sortBy('nome') as $role)
5 | hasRole($role->nome) ? 'checked' : ''}}> {{ $role->nome }}
6 | @endforeach
7 |
8 |
9 |
10 | Enviar
11 |
12 |
--------------------------------------------------------------------------------
/resources/views/users/index.blade.php:
--------------------------------------------------------------------------------
1 | @extends('master')
2 |
3 | @section('content_header')
4 | Pessoas
5 | @stop
6 |
7 | @section('content')
8 | @include('messages.flash')
9 | @include('messages.errors')
10 |
11 | Nº de Usuários Cadastrados: {{$users->count()}}
12 |
13 |
14 |
15 |
16 |
17 | Nome de Usuário
18 | Nome
19 | E-mail
20 | Grupos
21 | Ações
22 |
23 |
24 |
25 | @foreach($users as $user)
26 |
27 | {{ $user->username }}
28 | {{ $user->name }}
29 | {{ $user->email }}
30 |
31 |
32 | @forelse ( $user->roles()->get() as $role)
33 | {{ $role->nome }}
34 | @empty
35 | Sem grupo
36 | @endforelse
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 | @endforeach
46 |
47 |
48 |
49 | {{ $users->appends(request()->query())->links() }}
50 | @stop
51 |
52 |
--------------------------------------------------------------------------------
/resources/views/users/show.blade.php:
--------------------------------------------------------------------------------
1 | @extends('master')
2 |
3 | @section('content_header')
4 | {{ $user->username }}
5 | @stop
6 |
7 | @section('content')
8 | @include('messages.flash')
9 | @include('messages.errors')
10 |
13 |
14 |
15 |
16 | Nome: {{ $user->name }}
17 | Email: {{ $user->email }}
18 | Grupos:
19 |
20 | @foreach ( $user->roles()->get() as $role)
21 | {{ $role->nome }}
22 | @endforeach
23 |
24 |
25 |
26 |
27 |
28 |
31 |
32 | @stop
33 |
34 |
--------------------------------------------------------------------------------
/routes/api.php:
--------------------------------------------------------------------------------
1 | id === (int) $id;
16 | });
17 |
--------------------------------------------------------------------------------
/routes/console.php:
--------------------------------------------------------------------------------
1 | comment(Inspiring::quote());
18 | })->describe('Display an inspiring quote');
19 |
--------------------------------------------------------------------------------
/routes/web.php:
--------------------------------------------------------------------------------
1 | name('home');
15 |
16 | # Migração de equipamentos entre redes
17 | Route::get('redes/migrate', [RedeController::class,'migrate_form']);
18 | Route::post('redes/migrate', [RedeController::class,'migrate_store']);
19 |
20 | # resources
21 | Route::resource('equipamentos', EquipamentoController::class);
22 | Route::resource('redes', RedeController::class);
23 | Route::resource('roles', RoleController::class);
24 | Route::resource('users', UserController::class);
25 | Route::resource('files', FileController::class);
26 |
27 | # rotas para a senha única
28 | Route::get('/login/usp', [LoginController::class, 'redirectToProvider'])->name('loginusp');
29 | Route::get('/callback', [LoginController::class, 'handleProviderCallback']);
30 |
31 | # config
32 | Route::get('/config', [ConfigController::class, 'index']);
33 | Route::post('/config', [ConfigController::class, 'config']);
34 | Route::post('/freeradius/sincronize', [FreeradiusController::class, 'sincronize']);
35 | Route::get('/excel', [EquipamentoController::class, 'excel'])->name('excel');
36 |
37 | # Rotas para usuário local, podemos usar Auth::routes()
38 | Route::get('login', [LoginController::class, 'showLoginForm'])->name('login');
39 | Route::post('login', [LoginController::class, 'login']);
40 | Route::get('register', [RegisterController::class, 'showRegistrationForm'])->name('register');
41 | Route::post('register', [RegisterController::class, 'register']);
42 |
43 | # logout
44 | Route::post('/logout', [LoginController::class, 'logout']);
45 |
46 | # Logs
47 | Route::get('logs', '\Rap2hpoutre\LaravelLogViewer\LogViewerController@index')->middleware('can:admin');
48 |
--------------------------------------------------------------------------------
/server.php:
--------------------------------------------------------------------------------
1 |
8 | */
9 |
10 | $uri = urldecode(
11 | parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
12 | );
13 |
14 | // This file allows us to emulate Apache's "mod_rewrite" functionality from the
15 | // built-in PHP web server. This provides a convenient way to test a Laravel
16 | // application without having installed a "real" web server software here.
17 | if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
18 | return false;
19 | }
20 |
21 | require_once __DIR__.'/public/index.php';
22 |
--------------------------------------------------------------------------------
/storage/app/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !public/
3 | !.gitignore
4 |
--------------------------------------------------------------------------------
/storage/app/public/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/storage/framework/.gitignore:
--------------------------------------------------------------------------------
1 | config.php
2 | routes.php
3 | schedule-*
4 | compiled.php
5 | services.json
6 | events.scanned.php
7 | routes.scanned.php
8 | down
9 |
--------------------------------------------------------------------------------
/storage/framework/cache/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/storage/framework/sessions/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/storage/framework/testing/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/storage/framework/views/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/storage/logs/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/tests/CreatesApplication.php:
--------------------------------------------------------------------------------
1 | make(Kernel::class)->bootstrap();
20 |
21 | Hash::setRounds(4);
22 |
23 | return $app;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/tests/TestCase.php:
--------------------------------------------------------------------------------
1 |