mobileraker
mobileraker copied to clipboard
Config files access denied
Describe the bug When opening a '.cfg' file from the config files tab, files show a 401 error instead of actual data, cannot be edited in the app.
To Reproduce
- Go to 'Files' tab
- Tap on 'Configs'
- Tap on any '.cfg' file
- Editor shows the following content:
{"error": {"code": 401, "message": "Unauthorized", "traceback": "Traceback (most recent call last):\n\n File \"/home/pi/moonraker-env/lib/python3.9/site-packages/tornado/web.py\", line 1681, in _execute\n result = self.prepare()\n\n File \"/home/pi/moonraker/moonraker/app.py\", line 494, in prepare\n self.current_user = auth.check_authorized(self.request)\n\n File \"/home/pi/moonraker/moonraker/components/authorization.py\", line 741, in check_authorized\n raise HTTPError(401, \"Unauthorized\")\n\ntornado.web.HTTPError: HTTP 401: Unauthorized (Unauthorized)\n"}}
- Tap save button
- Error banner pops up with 'cannot save file'
Expected behavior Editor should load the file and be able to make changes to them. Saving should work without errors.
Screenshots
File content
Saving error
Smartphone (please complete the following information):
- Device: OnePlus 8T
- OS: Android 11
**Mobileraker-Version
- 1.6.2-16 (latest beta from Google Play Store)
Sorry for my late response. It seems like moonraker does not have the permission to access the config files. Ensure the file manager is configured correctly.
See https://moonraker.readthedocs.io/en/latest/configuration/#file_manager
Alternatively the authorization might be configured wrongly.
See
https://moonraker.readthedocs.io/en/latest/configuration/#authorization
Weird. I've followed (or at least copied) many of the config setups, so it should work. Here's my condensed moonraker.conf file:
# moonraker.conf
[server]
host: 0.0.0.0
port: 7125
[file_manager]
config_path: ~/klipper_config
log_path: ~/klipper_logs
enable_object_processing: True
[data_store]
temperature_store_size: 6000
gcode_store_size: 1000
[authorization]
force_logins: True
cors_domains:
*.local
*.lan
*://app.fluidd.xyz
trusted_clients:
10.0.0.0/8
127.0.0.0/8
169.254.0.0/16
172.16.0.0/12
192.168.0.0/16
192.168.2.59
FE80::/10
::1/128
# enables partial support of Octoprint API
[octoprint_compat]
# enables moonraker to track and store print history.
[history]
# Timelapse features here
...
# this enables moonraker's update manager
[update_manager]
enable_auto_refresh: True
channel: beta
# this enables fluidd updates
[update_manager client fluidd]
type: web
repo: fluidd-core/fluidd
path: ~/fluidd
# Timelapse update stuff here
...
[update_manager mobileraker]
type: git_repo
path: ~/mobileraker_companion
origin: https://github.com/Clon1998/mobileraker_companion.git
primary_branch:main
managed_services: mobileraker
env: ~/mobileraker-env/bin/python
requirements: scripts/mobileraker-requirements.txt
install_script: scripts/install-mobileraker-companion.sh
# KlipperScreen update stuff here
...
EDIT: I also have these set up as well:
# add virtual sd card
[virtual_sdcard]
path: ~/sdcard
[force_move]
enable_force_move: True
[pause_resume]
[gcode_arcs]
[exclude_object]
[endstop_phase]
What did I missed or misconfigured?
Sadly I am not an expert with moonraker and its config. However, does opening the config file work on any webinterface?
Yes it does. I use fluidd, and the web file manager works normally.
Hey due to other issues related to printer-url parsing.
Can you verify that the Printer-Address
in the Printer-Settings is correct?
For example, my printer runs on 192.168.178.135
therefore, the correct address should be http://192.168.178.135
.
Sorry for the late response. Yes, the printer address is set properly in the app, if that is what you meant by Printer-Address
Have the exact same issue. Really frustrating since everything else in the app works as expected.
Have the exact same issue. Really frustrating since everything else in the app works as expected.
Could you please post a screenshot of the printer configuration in mobileraker? Is most cases this is caused by a faulty configured http printer address.
I set-up my printer behind a reverse proxy (nginx proxy manager) so that I can remote anywhere and have a ssl certificat.
I set-up my printer behind a reverse proxy (nginx proxy manager) so that I can remote anywhere and have a ssl certificat.
I don't think the reverse proxy is the issue. After checking the relevant code section again I seem to have found the reason for the error. I simply forgot to correctly setup the HTTP call that is responsible for downloading any config file from moonraker. Therefore, Can you confirm that the app is showing a 400 status code instead of a 404?
Nope, error code is 401, unauthorized. Maybe I just missed some configuration? But again, everything else works as expected.
Nope, error code is 401, unauthorized. Maybe I just missed some configuration? But again, everything else works as expected.
No that's perfect! Its quite late and I confused 400 - Bad Request with 401 - Unauthorized.
This confirms my assumption that I simply forgot to include the header / ApiKey in the request that downloads the file. I will fix that in the next release. Sadly, there is no temporary workaround for this :(
Well at least now I know its just a bug and don't have to worry about it. I'll just wait until the next update.
Added in 2.5.0
Finally got the update on the app store (2.5.1) but still got the same exact issue.
Finally got the update on the app store (2.5.1) but still got the same exact issue.
Still 401?
Yup
Could you send me the logs of the app after you once more tried to open the file. The logs can be found at the bottom of the apps settings