Skip to content

Commit

Permalink
Fix more qBittorrent authentication bugs (#7501)
Browse files Browse the repository at this point in the history
* Fix qBittorrent not working on HTTPS

* Fix silent failures

* Get the API version on every call to `_get_auth`

(because qBittorrent could have been updated...)

* Update changelog

* config/search: add "verify cert option" for qBittorrent

* build themes

* Fix `torrents.verifyCert` config patch ignored warning

`Config patch ignored {'clients': {'torrents': {'verifyCert': True}}}`

* Update changelog
  • Loading branch information
sharkykh authored and p0psicles committed Dec 16, 2019
1 parent 9ef093b commit 57c0df1
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#### Fixes
- Fix Emby notifier error on Python 3 ([#7497](https://github.com/pymedusa/Medusa/pull/7497))
- Fix more qBittorrent authentication bugs ([#7501](https://github.com/pymedusa/Medusa/pull/7501))
- Fix `torrents.verifyCert` config patch ignored warning ([#7501](https://github.com/pymedusa/Medusa/pull/7501))

-----

Expand Down
20 changes: 13 additions & 7 deletions medusa/clients/torrent/qbittorrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def _get_auth(self):
auth = self._get_auth_legacy()
version = 1

# Authentication failed /or/ We already have the API version
if not auth or self.api:
if not auth:
# Authentication failed
return auth

# Get API version
Expand Down Expand Up @@ -87,8 +87,10 @@ def _get_auth_v2(self):
'password': self.password,
}
try:
self.response = self.session.post(self.url, data=data)
except Exception:
self.response = self.session.post(self.url, data=data, verify=app.TORRENT_VERIFY_CERT)
except Exception as error:
log.warning('{name}: Exception while trying to authenticate: {error}',
{'name': self.name, 'error': error}, exc_info=1)
return None

if self.response.status_code == 200:
Expand Down Expand Up @@ -121,15 +123,19 @@ def _get_auth_legacy(self):
'password': self.password,
}
try:
self.response = self.session.post(self.url, data=data)
except Exception:
self.response = self.session.post(self.url, data=data, verify=app.TORRENT_VERIFY_CERT)
except Exception as error:
log.warning('{name}: Exception while trying to authenticate: {error}',
{'name': self.name, 'error': error}, exc_info=1)
return None

# API v1.0.0 (qBittorrent v3.1.x and older)
if self.response.status_code == 404:
try:
self.response = self.session.get(self.host, verify=app.TORRENT_VERIFY_CERT)
except Exception:
except Exception as error:
log.warning('{name}: Exception while trying to authenticate: {error}',
{'name': self.name, 'error': error}, exc_info=1)
return None

self.session.cookies = self.response.cookies
Expand Down
11 changes: 6 additions & 5 deletions themes-default/slim/src/components/config-search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@
</select>
</config-template>

<config-toggle-slider v-show="clientsConfig.torrent[clients.torrents.method].verifyCertOption" v-model="clients.torrents.verifyCert" label="Verify certificate" id="torrent_verify_cert">
<config-toggle-slider v-show="clientsConfig.torrent[clients.torrents.method].verifySSLOption" v-model="clients.torrents.verifySSL" label="Verify certificate" id="torrent_verify_cert">
<p>Verify SSL certificates for HTTPS requests</p>
<p v-show="clients.torrents.method === 'deluge'">disable if you get "Deluge: Authentication Error" in your log</p>
</config-toggle-slider>
Expand Down Expand Up @@ -413,7 +413,7 @@ export default {
labelAnimeOption: true,
seedLocationOption: true,
pausedOption: true,
verifyCertOption: true,
verifySSLOption: true,
testStatus: 'Click below to test'
},
deluged: {
Expand All @@ -426,7 +426,7 @@ export default {
labelAnimeOption: true,
seedLocationOption: true,
pausedOption: true,
verifyCertOption: true,
verifySSLOption: true,
testStatus: 'Click below to test'
},
downloadstation: {
Expand All @@ -441,7 +441,7 @@ export default {
pathOption: true,
labelOption: true,
labelAnimeOption: true,
verifyCertOption: true,
verifySSLOption: true,
testStatus: 'Click below to test'
},
qbittorrent: {
Expand All @@ -450,12 +450,13 @@ export default {
labelOption: true,
labelAnimeOption: true,
pausedOption: true,
verifySSLOption: true,
testStatus: 'Click below to test'
},
mlnet: {
title: 'MLDonkey',
description: 'URL to your MLDonkey (e.g. http://localhost:4080)',
verifyCertOption: true,
verifySSLOption: true,
testStatus: 'Click below to test'
}
},
Expand Down
4 changes: 2 additions & 2 deletions themes/dark/assets/js/medusa-runtime.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions themes/light/assets/js/medusa-runtime.js

Large diffs are not rendered by default.

0 comments on commit 57c0df1

Please sign in to comment.