home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.52k stars 30.71k forks source link

set useragent in calDav integration #105292

Closed kaykoch closed 6 months ago

kaykoch commented 11 months ago

The problem

hello, I'm using Univention Server with openXchange mail/Calendar Integration. The forwarding to the OpenXchange service depends on the useragent. Agents as Thunderbird, Davx5 goes to OX. Mozilla is sent to UCS or Nextcloud. I would like to change the useragent for the caldav Integration by myself, so homeassistant requests are also forwarded to OX. I saw it in MyQ:

platform: myq
username: !secret myq_username 
password: !secret myq_password
type: chamberlain
user_agent: 'myQ/something'

What version of Home Assistant Core has the issue?

core-2023.12.0

What was the last working version of Home Assistant Core?

core-2023.12.0

What type of installation are you running?

Home Assistant OS

Integration causing the issue

calDav

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 11 months ago

myq documentation myq source

home-assistant[bot] commented 11 months ago

caldav documentation caldav source

tobixen commented 8 months ago

CalDAV-servers (or proxies) handling requests differently based on the User-Agent sound like a terrible design to me.

Looking into the python-caldav library it seems like it's currently possible to configure arbitrary headers to be sent in each and every request - except, the User-Agent will always be overwritten with Mozilla/5.0. That's obviously a bug, it should be the other way around, there should be a default User-Agent which can be overridden. I have no idea why the default value is set to Mozilla/5.0, I would like to change it - though for all I know there exists a server out there that will break if we change it, so better not to jinx the default :-)

tobixen commented 6 months ago

This is now possible in the master branch of the caldav library. For this feature to be available in HomeAssistant, I first need to do a release, then the version needs to be bumped in HomeAssistant, and then somebody else has to deem that it should be possible to configure it in the caldav integration and implement support for it.

joostlek commented 6 months ago

Although there is progress being made, I am going to close this as this is a feature request and not a bug.

joostlek commented 6 months ago

I think you can just continue the conversation, but it shouldn't be an open issue according to what rules apply to our issue tracker

tobixen commented 6 months ago

The possibility to send a user-defined User-Agent is definitively a feature-request. The use case here sounds a bit bizarre and unique, so I'm not sure if it belongs in HomeAssistant, but that's not up to me to decide.

I'm considering to also change the default User-Agent from "Mozilla" to "python-caldav" or something like that in the library - it would perhaps and perhaps not solve the problem reported by the original reporter. The Mozilla default was set by Cyril in 2010 or earlier, probably even before the first release - it does not really make sense to me. The question is just ... are there other systems out there that behaves differently dependent on the User-Agent header? Even the most innocent changes in this code has caused bug reports hitting me earlier. (and I've seen systems blocking traffic based on the User-Agent).