Commit Graph

23 Commits

Author SHA1 Message Date
SourceDoctor
11dfbc02b7 API Call to assign/remove a Portgroup to Ports (#13245)
* API Call to assign/remove a Portgroup to Ports

* .

* .
2021-09-21 08:41:01 -05:00
SourceDoctor
0d499b538b API port search by arbitrary field (#13231)
* DB Field specific Port Search

* .

* seperate function for API Call

* second parameter now optional

* code adjustments

* Update api_functions.inc.php

Co-authored-by: Tony Murray <murraytony@gmail.com>
2021-09-19 19:28:42 -05:00
geg347
6dbefd4a61 Adding API route to set bgpPeerDescr field (#13056)
* Adding API route to set bgpPeerDescr field

* Fixing CI test

* Fixing CI test part 2

* Adding validation of bgpPeerId as integer and changing SQL request with question mark syntax.

* Fixing CI test

* Following murrant's advices to protect against SQL injection

* Use built in json function

Co-authored-by: Tony Murray <murraytony@gmail.com>
2021-08-13 00:58:47 +02:00
Kevin Zink
93209a0fc8 API mac search (#12964)
* API find a switchport with the mac from device

* fix style

* convert SQL to Eloquent

* convert SQL to Eloquent

* git mistake

* Global use App\Models\Port

* git mistake partII

* Refractor Eloquent - Not finish but easier to help for others

* Better Eloquent Query without filter option

* Validation

* fix style

* Add filter option and DOC

* convert to the better macToHex method

* add a maxToHex unit test

* fix style

* fix style

* fix syle - seems my dev:check is running again :-)

* Fix phpStan

* phpStan #2
2021-08-09 19:33:04 -05:00
Misha Komarovskiy
e670097bf6 API: Add api call to list OSPF ports (#12955)
Signed-off-by: Misha Komarovskiy <zombah@gmail.com>
2021-06-16 20:31:05 +02:00
SourceDoctor
4b9e480118 Define Port Groups (#12402)
* Define Port Groups

* .

* .

* .

* API Calls

* .

* .

* .

* minor changes

* .

* update forms

* remove link

* .

* change column settings

* change migration

* change update position

* db migration fix

* .

* .

* .

* add missing doc reference

* update test data

* update test data

* update test data

* .

* .

* .

* .

* .

* .

* .

* .

* port group association in seperate table

* .

* .

* show all found groups on port

* select multiple Portgroups per Port

* change on migration file

* change query to eloquent

* Code changes

* move port group menu to ports main menu

* port group update to eloquent

* .

* .

* update to new setting way

* add missing merge parameter

* Use select2 and port some things to Laravel
some fixes, hopefully no new added bugs

* schema

* don't use on update restrict unfortunately

* remove unused import and revert changes

Co-authored-by: Tony Murray <murraytony@gmail.com>
2021-04-06 17:25:08 -05:00
SourceDoctor
9ade71d20c API Calls to list Device Outages, calculated Availability (#12103)
* API Calls to list Device Outages, calculated Availability

* switch to eloquent

* style correction
2020-09-24 00:21:08 +02:00
Jellyfrog
77c531527c Apply fixes from StyleCI (#12117)
* Apply fixes from StyleCI

* Disable style check
2020-09-21 14:54:51 +02: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
hachpai
4bb064c7ad Enabling general search for ports, devices, and more (#11571)
* Search engine for device, through API

* reviewed port search through API

* fixed die

* Update api_functions.inc.php

* Update api_functions.inc.php

* Update api_functions.inc.php

* Update api_functions.inc.php

* Update api.php

* Update api.php

* Update Ports.md

Co-authored-by: Tony Murray <murraytony@gmail.com>
2020-05-24 17:16:07 -05:00
gabrielRojasNew
6d22a885af Created add, edit, remove location and edit, remove services to the API (#11080)
* Created add, edit, remove location and edit, remove services to the v0 API and added their corresponding routes

* Changed repeating code by adding a function that checks for missing parameters

* Reduced the lines of add_service_for_host, modified a little more the missing fields function

* Changed True and False to true and false, erased an unused var called $missing

* Solved merged confict

Deleted duplicate functions generated when solving merge conflicts

* fixed more conficts

Deleting duplicate entries produced by trying to solve a merge conflict

* fixing more duplicate functions

This merge conflict created more duplicates

* Update api_functions.inc.php

* Update api_functions.inc.php
2020-02-26 11:12:36 +01:00
gabrielRojasNew
b47decdb00 Added add and remove parents for device from the V0 API (#11100)
* Added add and remove parents for device from the V0 API

* Fixed some minors errors (white spaces and lack of them, an unnecesary else)

* Added missing }

* Reducing cognitive complexity

* Further reduced cognitive complexity and added a check if parent device existed (it blew up when it did not)

* Refactored the code and fixed bugs (that i created) when deviceIds or parentIds where nonexistent

* Fixed } not on a new line issue

* Empty space removed

* Deleted lines added by mistake to composer.json

* removed a comma  that broke composer.json

* added the missing element in composer.json

* Added optional ids to del_parents_fom_host

Updated del_parents_from_host() so it can accept parent(s) id(s) to delete, if none given it deletes all it's parents.

* Fixing code issues on del_parents_from_host

Refactored and solved small issues with del_parents_from_host

* Refactored code del_parents_from_host

Refactored del_parents_from_host() in order to comply with the projects standard

* Added one space

Added missing whitespace

* refactoring for better readability
2020-02-13 22:28:43 +01:00
Albert Siersema
ae7eee438f Adds API to fetch all inventory items for a given device (#10885)
Adds API to fetch all inventory items for a given device
2019-12-17 13:49:13 +01:00
SourceDoctor
4232bf2f36 API Call for triggering Device discovery (#10861) 2019-12-08 22:17:27 +01:00
theochita
96ed161c81 Add ability to fetch oxidized device config via the librenms API (#10913)
* Add get_oxidized_config api route

* Add "get_oxidized_config" function.

* add get_oxidized_config docs and fix typo in the search_oxidized docs.
2019-12-08 20:04:53 +01:00
Tony Murray
12773d125b API: list_arp search by MAC (#10803)
* API: Allow search ARP by MAC

* reformat mac

* Update docs
2019-11-13 02:21:07 +00:00
Brian Sidebotham
67169bf7b9 Create device groups via API (#10791)
* Add POST ability to devicegroups API endpoint

* Simplify function and make use of Lavarel validation for API request
2019-11-08 13:11:56 +00:00
Tony Murray
717ecd4125 Fixed API arp cidr search (#10780) 2019-11-05 21:16:29 +00:00
theochita
25e8de30c1 Implement Oxidized "config search" as an API (#10648)
* Implement Oxidized config search as API

* Add Oxidized config search DOC.

* Update Devices.md

* change /configsearch/{searchstring} to /config/search/{searchstring}

* Update Devices.md
2019-10-17 02:46:44 +00:00
Tony Murray
f1c67ac5f4 Ports API: Workaround for ifNames with slashes (#10502)
* Workaround for ifNames with slashes

Basically,

/api/v0/devices/3/ports/0%2f4 -> /api/v0/devices/3/ports/ifName?ifName=0/4
/api/v0/devices/3/ports/0%2f4/port_bits -> /api/v0/devices/3/ports/ifName/port_bits?ifName=0/4

Or you can just use port_id.

* Fix API ports using ifName with slashes
hand parse the path for the ports graph endpoints
this way we can respect the original way of handling slashes (%2F)
2019-08-12 09:46:36 -05: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
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