Commit Graph

25 Commits

Author SHA1 Message Date
Jellyfrog
2b3575a5e9
Laravel 10.x Shift (#14995)
* Apply code style

* Remove explicit call to register policies

* Shift core files

* Shift config files

* Default config files

In an effort to make upgrading the constantly changing config files
easier, Shift defaulted them and merged your true customizations -
where ENV variables may not be used.

* Bump Laravel dependencies

* Add type hints for Laravel 10

* Shift cleanup

* wip

* wip

* sync translation

* Sync back config

* Public Path Binding

* QueryException

* monolog

* db::raw

* monolog

* db::raw

* fix larastan collections

* fix phpstan bug looping forever

* larastan errors

* larastan: fix column type

* styleci

* initialize array

* fixes

* fixes

---------

Co-authored-by: Shift <shift@laravelshift.com>
2023-05-24 22:21:54 +02:00
Tony Murray
52f5f10231
Fix some lint issues (#14962) 2023-04-15 09:02:41 -05:00
Tony Murray
7dd3a224fa
Block disabled user session auth (#14473)
Do not allow users that are disabled to be logged in via cookie.
Allow all auth methods to disable users
2022-10-17 12:39:15 -05:00
Tony Murray
50cf1a49f1
Kick other sessions when changing password (#13194)
* Kick other session when changing password
Invalidate other sessions when a user password gets changed

* Don't logout admin users when they change passwords.
Cleanup phpstan exceptions

* only restore user if needed

* comment odd behavior

* $current_user typehint
2021-10-21 17:25:38 -05:00
Tony Murray
1afc6abdb5
Always return json for api requests (#12335)
even if the client does not properly request it
2020-11-22 03:21:47 +01:00
Jellyfrog
b7676e4cc8
Update to Composer 2 (#12263)
* Update to Composer 2

No need to roll our own checks anymore since this is now built in.
Also limit the update check to once a week.

* update

* Make Composer wrapper report correct exit code

* Update composer_wrapper.php

* re-enable extension check

Co-authored-by: Tony Murray <murraytony@gmail.com>
2020-11-09 00:28:07 -06:00
Jellyfrog
50c8033099
Laravel 8.x Shift (#12235)
* Shift HTTP kernel and middleware

* Shift service providers

* Shift console routes

* Shift to class based factories

* Namespace seeders

* Shift PSR-4 autoloading

* Default config files

In an effort to make upgrading the constantly changing config files
easier, Shift defaulted them. This allows you to review the commit
diff for once for customizations when you are done Shifting.

Moving forward, consider using ENV variables or create a separate
config file to allow the core config files to remain as default
as possible.

* Shift Laravel dependencies

* Shift return type of base TestCase methods

From the [PHPUnit 8 release notes][1], the `TestCase` methods below now declare a `void` return type:

- `setUpBeforeClass()`
- `setUp()`
- `assertPreConditions()`
- `assertPostConditions()`
- `tearDown()`
- `tearDownAfterClass()`
- `onNotSuccessfulTest()`

[1]: https://phpunit.de/announcements/phpunit-8.html

* Shift cleanup

* console routes

* composer update

* factories

* phpunit

* bootstrap pagination

* model factory

* wip

* Apply fixes from StyleCI (#12236)

* wip

* Apply fixes from StyleCI (#12238)

* wip

* wip

* wip

* wip

* Apply fixes from StyleCI (#12240)

* wip

* Apply fixes from StyleCI (#12242)

* composer update

* Bump to PHP 7.3 minimum

Co-authored-by: Laravel Shift <shift@laravelshift.com>
2020-11-03 10:18:31 -06:00
Jellyfrog
f526ba326b
Laravel 7.x Shift (#11676)
* Shift bindings

PHP 5.5.9+ adds the new static `class` property which provides the fully qualified class name. This is preferred over using class name strings as these references are checked by the parser.

* Shift core files

* Shift to Throwable

* Shift Laravel dependencies
Add laravel/ui dependency
Use our fork of string-blade-compiler

* Shift config files

Default config files

In an effort to make upgrading the constantly changing config files
easier, Shift defaulted them so you can review the commit diff for
changes. Moving forward, you should use ENV variables or create a
separate config file to allow the core config files to remain
automatically upgradeable.

Restore config header comment

* Remove duplicate named routes

* add basic trust host middleware

* Trusted proxies should be default null

* Fix missed rename

* wip

* Rename routes

* Update trustedproxy.php

* Update Kernel.php

* revert trustedproxy.php

It only accepted '*' and not ['*']

* Fix tests

fake request was causing the error

Co-authored-by: Laravel Shift <shift@laravelshift.com>
Co-authored-by: Tony Murray <murraytony@gmail.com>
2020-07-09 08:22:50 -05:00
Tony Murray
560fd71ef6
CORS settings in webui (#11912)
* Change CORS implementation
allows for upstream integration of Laravel 7

* migrate config

* skip implementing patterns for now

* Expose settings to the webui

* Make db settings apply
2020-07-08 07:36:51 -05:00
Tony Murray
4b4f321680
Fix external auth auto-login (#11813)
* Fix external auth auto-login
rename auth middlewares so LegacyExternalAuth is registered on the Auth::routes() login route.

* External auth before authenticate
2020-06-12 16:06:50 -05:00
Tony Murray
5c6c8844e8
Auth middleware refinement (#11767)
* auth middleware group

* dummy page for legacy php scripts instead of recursively calling init.php

* Test and fix routing scenarios

* fix api auth

* disable unused auth routes
2020-06-05 11:50:58 -05:00
Jellyfrog
b09bc07f8f
Laravel 6.x (#11397)
* Update Laravel core files

Fix app/Http/Kernel.php

* Use RouteServiceProvider::HOME

* Sync Laravel default config files

* Update composer dependencies to Laravel 6

* fix resources/lang/en/validation.php

* Manually fixing tests

required by travis, fails locally???

* Update wpb/string-blade-compiler

* Add new viewany() authorization policies

* Update minimum PHP version to 7.2

* Re-generate our json test-dumps

Due to:
https://github.com/laravel/framework/pull/16069
https://github.com/laravel/framework/pull/31100

* update truenas data

* fix truenas

Co-authored-by: Laravel Shift <shift@laravelshift.com>
Co-authored-by: Tony Murray <murraytony@gmail.com>
2020-05-23 12:05:18 -05:00
SourceDoctor
a9212faa83 Allow user specific themes (#10799)
* allow user specific themes

* add missing newline

* use global function getDefinitions

* some fixes

* .

* travis fix

* .

* Optimize preference loading
Aka, don't run multiple sql queries per page load, now it is 0-1 queries (for preferences)

* Add a default option for user preferences

* Remove unused code

* more
2019-11-14 18:40:38 +00:00
Tony Murray
e6423852ef
Remove $_SESSION usage, except install (#10745)
* Remove $_SESSION usage, except install
Fixes issue with device debug capture
Removes secure_cookies setting, use the .env variable SESSION_SECURE_COOKIE instead.  Reminder secure cookies requires cookies are transported over https, if everything is already transported via https, the setting won't make a difference.

* Fix availability map controls
2019-10-26 00:29:12 +00:00
Tony Murray
89fae9be1d
Move API routing to Laravel (#10457)
* Add more api helper functions
to centralize code more

* Enable cors

* Initial Legacy route in Laravel

* Force api v0 responses to json
Add a couple more routes

* more paths, pretty print the json response
pass parameters to the api function

* devices basic functions

* Port generic graph function
check permissions function accepts callback to avoid lots of if statements

* move vlans

* links

* graphs

* fdb

* health

* wireless

* port graphs

* ip functions
split em up

* port_stack

* components

* compoment add/edit/delete

* get_device_groups

* port stats

* port graphs

* get_devices_by_group

* port_groups

* api_get_graph

* show_endpoints

* get_bill

* get_bill_graph

* get_bill_graphdata

* get_bill_history

* get_bill_history_graph

* remaining bill functions

* list_alerts

* ack/unmute alert

* Some cleanups

* Some cleanups

* list_alert_rules

* alert rule add/edit/delete

* inventory

* list_cbgp

* vrf

* list_ipsec

* list_fdb

* list_links (fix both usages)

* list_locations

* list_locations

* list_vlans

* list_ip_addresses

* list_arp

* list_ip_networks

* cleanup

* services

* list_logs and fix authlog.......

* cleanup

* cleanup 2

* remove slim

* don't load schema more than once

* basic test

* fix style

* downgrade laravel-cors to a version that supports PHP 7.1
2019-07-29 16:32:37 -05:00
Tony Murray
90a67c2ece
User configurable locale (language) (#10204)
* Support for system APP_LOCALE

* Start preferences re-write

* port 2fa form

* Working user preferences

* Language user preference

* Don't look up locale from the DB every request

* Device list working

* Deny demo user middleware

* Finish password changing

* remove used resource methods

* remove leftover use

* warn that translation is incomplete

* fix style
2019-05-23 10:05:45 -05:00
Tony Murray
e18f4522d5
Update to Laravel 5.7 (PHP 7.3 support) (#9800)
* Move assets to 5.7 location

* Add 5.7 SVGs

* add cache data dir

* update QUEUE_DRIVER -> QUEUE_CONNECTION

* Update trusted proxy config

* update composer.json

* 5.5 command loading

* @php and @endphp can't be inline

* Laravel 5.6 logging, Nice!

* Update blade directives

* improved redirects

* remove unneeded service providers

* Improved debugbar loading

* no need to emulate renderable exceptions anymore

* merge updated 5.7 files (WIP)

* Enable CSRF

* database_path() call causes issue in init.php

* fix old testcase name

* generic phpunit 7 fixes

* add missed file_get_contents
Keep migrations table content

* fix duplicate key

* Drop old php versions from travis-ci

* remove hhvm

* fix code climate message

* remove use of deprecated function assertInternalType

* Disable CSRF, we'll enable it separately.
All forms need to be updated to work.

* Update document references
2019-02-12 17:45:04 -06:00
Tony Murray
14a168b2a9
Keeps the dashboard sessions from expiring. (#9263)
* Keeps the dashboard sessions from expiring.
Route dashboard ajax calls through Laravel.
Boots minimal cookies and sessions.
Does not fix other pages for now, real fix is to fully port.

* Check Laravel auth for the legacy calls.
Display Laravel errors in the dashboard.
legacy auth checks are mostly extraneous now.
2018-09-30 21:23:00 -05:00
Tony Murray
fc12175ee0 Fixed remember me for login (#9233)
remember me and AuthenticateSession are incompatible on Laravel 5.4

6ca154f2b6

More info: https://kfirba.me/blog/the-undocumented-authenticatesession-middleware-decoded

DO NOT DELETE THIS TEXT

#### Please note

> Please read this information carefully. You can run `./scripts/pre-commit.php` to check your code before submitting.

- [x] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/)

#### Testers

If you would like to test this pull request then please run: `./scripts/github-apply <pr_id>`, i.e `./scripts/github-apply 5926`
After you are done testing, you can remove the changes with `./scripts/github-remove`.  If there are schema changes, you can ask on discord how to revert.
2018-09-19 23:05:32 +01:00
Tony Murray
173b1339e9 Fixed install.php not redirecting when it should (#9224)
DO NOT DELETE THIS TEXT

#### Please note

> Please read this information carefully. You can run `./scripts/pre-commit.php` to check your code before submitting.

- [x] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/)

#### Testers

If you would like to test this pull request then please run: `./scripts/github-apply <pr_id>`, i.e `./scripts/github-apply 5926`
After you are done testing, you can remove the changes with `./scripts/github-remove`.  If there are schema changes, you can ask on discord how to revert.
2018-09-18 20:56:48 +01:00
Neil Lathwood
57b16c77bf
Remove api rate limits (#9211) 2018-09-16 17:17:02 +01:00
Tony Murray
79333c45f6
Allow trusted proxy via APP_TRUSTED_PROXIES (#9196)
* Allow trusted proxy via APP_TRUSTED_PROXIES
Set to '*' by default to emulate legacy behavior.
Set up doc describing environment variables

* Create helper to parse environment variables into arrays properly.

* Update doc blocks
2018-09-13 07:26:42 -05:00
Tony Murray
46d5333d1b
Init and refresh the php session each page load (#9186) 2018-09-12 08:12:19 -05:00
Tony Murray
32a7c50189
Use Laravel authentication (#8702)
* Use Laravel for authentication
Support legacy auth methods
Always create DB entry for users (segregate by auth method)

Port api auth to Laravel

restrict poller errors to devices the user has access to

Run checks on every page load.  But set a 5 minute (configurable) timer.
Only run some checks if the user is an admin

Move toastr down a few pixels so it isn't as annoying.

Fix menu not loaded on laravel pages when twofactor is enabled for the system, but disabled for the user.
Add two missing menu entries in the laravel menu

Rewrite 2FA code
Simplify some and verify code before applying

Get http-auth working
Handle legacy $_SESSION differently.  Allows Auth::once(), etc to work.

* Fix tests and mysqli extension check

* remove duplicate Toastr messages

* Fix new items

* Rename 266.sql to 267.sql
2018-09-11 07:51:35 -05:00
Tony Murray
1ad7f3138b
Add Laravel to LibreNMS (#8318)
* Add Laravel to LibreNMS.

* Try to set permissions during initial install and first composer update to Laravel.

* Fix composer.lock
Fix missing db config keys

* Start building v1 layout
Port ajax_setresolution, inject csrf into jquery ajax calls
Layout works, building menu
Partially done.

* Fix device group list
remove stupid count relationships

* Print messages for common boot errors.
Don't log to laravel.log file.
Log to error_log until booted, then librenms.log

* Fix up some issues with Config loading
Start of custom directives

* Custom blade directives: config, notconfig, admin

* Preflight checks
Only load config files once.

* Update the composer.lock for php 5.6

* Menu through routing

* Start of alert menu

* Better alert scopes

* reduce cruft in models

* Alerting menu more or less working :D

* Fix style

* Improved preflight

* Fix chicken-eggs!

* Remove examples

* Better alert_rule status queries
Debugbar

* fix app.env check

* User Menu

* Settings bar (dropped refresh)
Search JS

* Toastr messages

* Rename preflight

* Use hasAccess(User) on most models.
Add port counts

* Missed a Preflight -> Checks rename

* Fix some formatting

* Boot Eloquent outside of Laravel
Use Eloquent for Config and Plugins so we don't have to connect with dbFacile inside Laravel.
Move locate_binary() into Config class

* Config WIP

* Try to fix a lot of config loading issues.

* Improve menu for non-admins removing unneeded menus
url() for all in menu

* Only use eloquent if it exists

* Include APP_URL in initial .env settings

* Implement Legacy User Provider

* Helper class for using Eloquent outside of Laravel.
Allows access to DB style queries too and checking the connection status.

* Fix up tests

* Fix device groups query

* Checking Travis

* copy config.test.php earlier

* dbFacile check config before connecting
Don't use exception to check if eloquent is connected, it gets grabbed by the exception handler.
Ignore missing config.php error.

* Fix config load with database is not migrated yet.

* Remove Config::load() from early boot.

* Use laravel config settings to init db (this prefers .env settings)
Fix bgp vars not set in menu
add _ide_helper.php to .gitignore

* Restrict dependencies to versions that support php 5.6

* Update ConfigTest

* Fix a couple of installation issues

* Add unique NODE_ID to .env

* Correct handling of title image

* Fix database config not loading. Thanks @laf

* Don't prepend /

* add class_exists checks for development service providers

* Fix config value casting

* Don't use functions that may not exist

* Update dbFacile.php

* d_echo may not be defined when Config used called.

* Add SELinux configuration steps
More detailed permissions check.
Check all and give complete corrective commands in one step.

* Ignore node_modules directory

* Re-add accidetal removal
2018-05-09 08:05:17 -05:00