baseURL needs to be prefixed manually, since
PlayWright will use `new URL` internally which
interprets our paths relative to the domain,
not any paths provided as well.
Errors during install, e.g. due to dependency issues, that
happened while a "Requirement already installed" message
was present in the output as well, were wrongly read as
a "reinstall needed" case if there was no failure line
present for some reason.
The logic has now been adjusted so that a reinstall will
only be triggered if there was no `Error:` line in the
output. A test case has been added as well.
Closes#4703
- users.yaml is now versioned, and a backup is made
on version change. Thus, before any of the new
hashes are being saved to it, a backup with the
old ones will be made, here users.v1.yaml.
- The no longer needed salt is removed from the
config if no legacy hashes are left in
users.yaml. Prior to this removal however, a
backup of config.yaml is made,
config.cleanup_legacy_hashes.yaml.
When rolling back to an earlier version of
OctoPrint, moving both backups back over to
config.yaml and users.yaml respectively and
restarting will restore the ability to login
again.
* 🔒️ Tie remember_me cookie to password hash
That way when the password gets changed,
existing cookies automatically get
invalidated.
* 🔒️ Invalidate user sessions on password change
This will require a user to log in again after
their password is changed, either by themselves
or through an admin.
This is a slight change in behaviour compared
to before, but makes sure password changes
are enforced across all existing sessions.
* ♻️ remember_key_for_user => signature_key_for_user
* 🔒️ Invalidate sessions after 15min of inactivity
The server has been keeping track of login
session for a while, but now it also only
considers such (active login) sessions fresh
that have been active within the past 15min.
That way, a session cookie's lifetime is now
also restricted server side. An active
socket connection suffices to keep the
session alive, as do any other requests
using the cookie.
As the session tracking happens in-memory,
all sessions will become invalid on server
restart. However, if the remember me cookie
is set, after server restart a passive
login will succeed.
* 🔒️ Limit remember_me validity to 90 days
So far that was only done through the cookie
duration, and with a year to boot. Now we
encode the creation date into the cookie
and check against that, if it exceeds the
cookie duration the cookie is considered
unset.
Will prevent reuse of ancient remember me
cookies (and force the user to login at
least once every 90d).
* 💚 Fix unit tests
New cookie handling requires a faked flask
config object.
Related: https://huntr.dev/bounties/d27d232b-2578-4b32-b3b4-74aabdadf629/
- Use "M20 L T" (if CAPABILITY_EXTENDED_M20 is available) which gives
us long file names but also file timestamps.
- Wire up that timestamp into "date" field which gives us "Uploaded: ...
ago" for files on SD card. Sorting by upload date also works.
- Implementing this also fixes parsing of response to (for example
manually sent) "M20 T" command. Octoprint assumed that third entry
in response is always long file name while with M20 T it is timestamp.
- Add conversion routines between M20 T timestamp and unix timestamp. Wire
up that conversion in virtual printer.
See also https://reprap.org/wiki/G-code#M20:_List_SD_card
* Notify user if file or folder removal fails
* Improve error messages for failed file or folder removal
* Notify user if file is too large to upload
* Improve notification for failed file and folder uploads
The redirect parameter to the login dialog now gets restricted to local URLs (as detected by unset scheme & netloc) that match a short list of allowed endpoints routes.
This protects against lines from the printer like
T:210.04 /210.00 B:52.00 /52.00 @:85 B:1234.0 /1234.0
We've seen *so* much weird stuff out there in firmware, let's better
be safe rather than sorry and rule out latter values from overwriting
former values just in case.
* Fix too broad regex
* Fix lack of error handling in case of reserved identifier
All of these got already introduced in 1.4.1, but now with #4388
they are WAY more likely to pop up (e.g. in garbage lines too) and
completely nuke the connection.
Closes#4456
Ever since the needed upgrade, the e2e tests have
been very shaky. Let's try to up the retry count
to get this under control.
Long term I need to find out what's going on,
but currently I'm not able to even reproduce the
issue (jquery not loading). And/or maybe switch
to PlayWright if I can't get it to work reliably
anymore.
* Use json for annoucements cache
Parsing this XML file is very slow, so there's no reason to do it more
than we have to.
See 4480-2021-12-11T13:23:48-05:00.json, MainThread -> parse
On my system, this reduces the time for /plugin/announcements/channels
from 250ms CPU time to 50ms.
The rough improvment in this specific function call is from 8% to 0.32%
of total runtime.
* ♻️ Refactor json serializer
* Move back to octoprint.util.json
* Leave old encoding helper as is but add additional
one focused on serialization (with full roundtrips).
Use each as needed (primarily encoding one).
octoprint.util.encoding -> old one
octoprint.util.serializing -> new one
Each serves different purpose, we don't want
to end up with `__jsonclass__` stuff in our
API output at some point, so separate the
concerns here and allow different handling.
* Ensure wrappers are in place for backwards
compatibility (e.g. dump vs dumps).
* 🐛 Fix handling of invalid cache
We get different exceptions now and in any case just throw
*anything* away that we can't parse.
* 🎨 Use fallback typing annotation for Py3.7.{0,1}
Better solution than getting stuck to Dict only, thanks
@flaviut for the suggestion!
* 🐛 Fix bytes encoding
bytes objects are explicitly not always UTF-8, so encode them in a way
that doesn't lead to errors and encoding/decoding problems when they are
actually binary data.
Co-authored-by: Gina Häußge <gina@octoprint.org>