1237 Commits

Author SHA1 Message Date
Eric Callahan
9b9a6d0646
http_client: remove escape_url method
This method will not work correctly if any individual part contains
a special character.  For example, if an item in the path contains
a "#", the regex will return an incorrect result.  Likewise, if any item
in a query string contains an "&" the query string will be correctly
escaped.

All urls supplied to the http client must be escaped by the consumer.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-11 11:43:17 -05:00
Eric Callahan
0b4e604c95
webcam: remove call to escape_url
The configured url should already be escaped.  It isn't possible to
reliably quote a full url if any of the parts contain special characters.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-11 11:43:16 -05:00
Eric Callahan
5661b0216c
simplyprint: remove call to escape_url
The url received from SimplyPrint should already be escaped.  It
isn't possibly to reliably quote a full url if any of the parts contain
special characters.

This commit also corrects some minor type checking issues.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-11 11:43:16 -05:00
Eric Callahan
55ebe120c5
power: resolve url encoding issues
Dynamic parts of the url must be encoded individually to
guarantee correct url generation.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-11 11:43:15 -05:00
cmerkle
0de712e822
power: add support for Hue device groups
Signed-off-by: Clayton Merkle <clay.merkle@gmail.com>
2023-02-09 11:15:27 -05:00
Eric Callahan
5325693ed6
machine: report provider in system_info
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-08 17:44:57 -05:00
Eric Callahan
8c7b93c6dd
machine: fix supervisord active state reporting
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-08 17:00:39 -05:00
Eric Callahan
8010f1dda2
machine: add shutdown action option
Signed-off-by:  Eric Callahan <arkisne.code@gmail.com>
2023-02-08 11:11:34 -05:00
Eric Callahan
f0b82afde4
machine: remove unnecessary supervisord handlers
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-08 06:02:25 -05:00
Eric Callahan
645f0c9acf
machine: add container detection logging
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-08 06:00:01 -05:00
Eric Callahan
b02224485e
machine: rename supervisord provider
This is a cli providers, so rename it to supervisord_cli.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-08 05:36:57 -05:00
Eric Callahan
d9579c9374
shell_command: allow optional success codes
Some commands may return codes other than zero on a successful
return.  Allow callers to specify an optional list of return codes that
will return success without raising an exception.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-07 19:10:18 -05:00
Eric Callahan
c69441955a
machine: support supervisord service info extraction
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-07 19:10:17 -05:00
Eric Callahan
5aa645f974
machine: simplify extract_service_info() call
Don't require the caller to specifiy properties, use the default
property list if not specified.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-07 19:10:17 -05:00
Eric Callahan
2fb136449a
machine: fix supervisorctl command arguments
According to the supervisord documentation the `-c` option is used to
specify the configuraiton file.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-07 19:10:17 -05:00
Eric Callahan
8335906443
machine: automate supervisord process init
Don't hardcode klipper and moonraker, detect them along with all other
allowed services.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-07 19:10:16 -05:00
Eric Callahan
5807757efa
Revert "announcements: enable dev_mode when the debug flag is set"
This reverts commit 83e0947d312e44843807777bfee504aab48de89a.
2023-02-07 19:09:14 -05:00
Eric Callahan
385b9a1b7a
update_manager: handle rev-list on tagless repos
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-07 11:20:08 -05:00
Eric Callahan
d75831f10a
update_manager: require at least two parts in a tag
Allowing only a single part in the regex resulted in repos
without tags being assigned erronous version info.  With
this change, the following tags can be parsed:

v1.0
v1.0.2
1.0
1.0.2

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-07 11:09:50 -05:00
Eric Callahan
c331c5a7d7
update_manager: fix semver conversion
When converting a semantic version to a list for comparisons
guarantee that the base version has 3 parts.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-07 10:28:36 -05:00
Eric Callahan
4ff7a50821
update_manager: relax semantic tag requirement
Allow tags versions with one, two, or three parts.  The following
examples are now valid:

v1
v1.3
v1.0,10

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-07 08:06:13 -05:00
Eric Callahan
83e0947d31
announcements: enable dev_mode when the debug flag is set
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2023-02-06 18:12:29 -05:00
Eric Callahan
4af483c786
database: remove unnecessary BytesIO conversion
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-06 15:22:46 -05:00
Eric Callahan
559df5aea1
websockets: implement websocket-klippy bridge
Provide a new websocket implementation that creates a near one to one
bridge with a Unix Socket connection to Klippy.  This may be used to
access Klippy APIs not otherwise available over the primary websocket,
such as the various "dump" commands.

Unlike the primary websocket Moonraker does not decode or inspect
data that passes through the bridge.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-06 15:22:45 -05:00
Eric Callahan
f9086181b8
moonraker: bump API version to 1.2.0
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-06 11:24:17 -05:00
Eric Callahan
01977c8775
update_manager: refactoring
Code style and naming convention improvements.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-06 07:50:08 -05:00
Eric Callahan
c8ad69b902
update_manager: add individual refresh endpoint
This endpoint allows clients to refresh items on an individual basis
when the "name" parameter is specified.  This endpoint replaces

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-06 06:42:56 -05:00
Eric Callahan
f50fa3c5e7
update_manager: add package resolution check to apt backend
Make sure packages within the package list exist prior to installation.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-05 19:25:54 -05:00
Eric Callahan
21a7928ea2
update_manager: pip improvements
Re-implement pip updates using a pinned version.  A version
check is now always done prior to installing python requirements,
updating when necessary.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-05 19:25:54 -05:00
Eric Callahan
76500fe9f9
update_manager: improve dependency detection
Parse system packages and python requirements prior to and after each
updating, using the difference to determine if an update is necessary.
Only the new detected packages are installed unless the "force" variable
is set.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-05 19:25:53 -05:00
Eric Callahan
a413f4e4cd
websockets: guarantee subscription removal
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-04 16:46:03 -05:00
Eric Callahan
1be19be747
klippy_connection: rework klippy initialization
Handle a race condition where a shutdown event could be received
from the webhooks subscription during initialization.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-04 16:43:35 -05:00
Quinn Damerell
babf97be3b Adding OctoEverywhere to the default service list
module: Adding OctoEverywhere to the default service list.

Adding OctoEverywhere to the default service list in machine.py so future installs of moonraker will allow the octoeverywhere service to be managed from frontends.

Signed-off-by: Quinn Damerell <quinnd@outlook.com>
2023-02-03 19:09:34 -05:00
Eric Callahan
c1e4142a40
update_manager: add arch filter
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-01-31 14:00:54 -05:00
Eric Callahan
b02e766a4d
update_manager: log detected packages
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-01-31 14:00:54 -05:00
Eric Callahan
fb618a46fd
file_manager: fix thumbnails endpoint registration
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-01-31 14:00:33 -05:00
Eric Callahan
55e852cd87
file_manager: add thumbnail request endpoint
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-01-31 06:13:44 -05:00
Eric Callahan
12b1befcbc
authorizaton: type checking fix
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-01-24 07:08:23 -05:00
Eric Callahan
d8941b3fb2
websockets: sanitize verbose logging
When verbose logging is enabled sanitize credentials from JSON-RPC
requests and responses.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-01-24 06:13:54 -05:00
Eric Callahan
a5161816a7
websockets: decode jwts on authorized connections
Unix sockets never require authentication and it is possible for
Websocket connections to authenticate with the request itself.
In these cases the `identify` endpoint must still process an
access_token if provided, as it allows the front end to assign
the desired user to the connection.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-01-24 06:13:54 -05:00
Eric Callahan
80862799ed
websockets: require re-auth on user logout
Propagate user state changes to open websockets and unix sockets.
If a websocket's user is logged out require re-authentication.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-01-24 06:13:53 -05:00
Eric Callahan
06ec5541e3
websockets: add support for API Key authentication
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-01-24 06:13:53 -05:00
Eric Callahan
eca4c7e438
authorization: limit failed login attempts
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-01-24 06:13:52 -05:00
Eric Callahan
9d6719ed31
websockets: set a websocket connection limit
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-01-24 06:13:52 -05:00
Eric Callahan
5a22b21a40
authorization: relax auth header requirements
Don't raise an exception if the authorization header contains an
invalid value, such as Basic auth.  Ignore it and move on to the
next step in authentication.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-01-24 06:13:52 -05:00
Eric Callahan
4ca39bec0a
authorization: authenticate over websocket
Register all of the "access" endpoints with the websocket.  Front
ends may now connect to the websocket without an oneshot token
and login.  If the front end already has a JWT for the user it
can be passed to the "identify" endpoint to authenticate directly.

Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2023-01-24 06:13:51 -05:00
Eric Callahan
c83714bfe8
authorization: make api key authentication optional
Signed-off-by;  Eric Callahan <arksine.code@gmail.com>
2023-01-24 06:13:51 -05:00
Eric Callahan
2ad7a6a087
power: log the traceback on device init errors
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-01-18 19:31:47 -05:00
Eric Callahan
db81607370
machine: use direct systemctl commands for reboot/shutdown
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-01-16 12:42:21 -05:00
Eric Callahan
a154c5fa51
machine: add moonraker-obico to default services
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-01-12 18:10:30 -05:00