Commit 619e8648 authored by echel0n's avatar echel0n
Browse files

refactored log level of rarbg provider to debug for rarbg api returned errors

refactored SiCKRAGE SSO URL
parent 7c123cd4
......@@ -28,6 +28,11 @@ from keycloak.realm import KeycloakRealm
import sickrage
class KeycloakOpenidConnectCustom(KeycloakOpenidConnect):
def get_path_well_known(self):
return "realms/{}/.well-known/openid-configuration"
class AuthServer(object):
__server = {}
__client = {}
......@@ -46,7 +51,7 @@ class AuthServer(object):
def health(self):
for i in range(3):
try:
health = requests.get("{base}/auth/realms/{realm}".format(base=self.server_url, realm=self.server_realm), verify=False, timeout=30).ok
health = requests.get("{base}/realms/{realm}".format(base=self.server_url, realm=self.server_realm), verify=False, timeout=30).ok
except (requests.exceptions.ConnectionError, requests.exceptions.ReadTimeout):
pass
else:
......@@ -81,7 +86,7 @@ class AuthServer(object):
return self.client.logout(*args, **kwargs)
def decode_token(self, *args, **kwargs):
return self.client.decode_token(*args, **kwargs)
return self.client.decode_token(*args, **kwargs, audience='sickrage-api')
def refresh_token(self, *args, **kwargs):
if not self.health:
......@@ -111,7 +116,7 @@ class AuthServer(object):
def __get_client(self) -> KeycloakOpenidConnect:
client = self.__client.get('client', None)
if client is None:
self.__client.update({'client': self.__get_server().open_id_connect(self.client_id, '')})
self.__client.update({'client': KeycloakOpenidConnectCustom(self.__get_server(), self.client_id, '')})
client = self.__client.get('client', None)
return client
......
......@@ -18,7 +18,7 @@
# You should have received a copy of the GNU General Public License
# along with SiCKRAGE. If not, see <http://www.gnu.org/licenses/>.
# ##############################################################################
from urllib.parse import urlencode
import sickrage
from sickrage.core.webserver.handlers.base import BaseHandler
......@@ -34,6 +34,13 @@ class LogoutHandler(BaseHandler):
self.clear_cookie('_sr_refresh_token')
if logout_uri:
return self.redirect(f'{logout_uri}?redirect_uri={redirect_uri}', add_web_root=False)
# logout_args = {
# 'post_logout_redirect_uri': redirect_uri,
# 'id_token_hint': sickrage.app.api.token['access_token'],
# 'state': sickrage.app.api.token['session_state'],
# }
#
# return self.redirect(f'{logout_uri}?{urlencode(logout_args)}', add_web_root=False)
return self.redirect(f'{logout_uri}', add_web_root=False)
else:
return self.redirect(f'{redirect_uri}', add_web_root=False)
......@@ -155,16 +155,16 @@ class RarbgProvider(TorrentProvider):
# List of errors: https://github.com/rarbg/torrentapi/issues/1#issuecomment-114763312
if error_code == 5:
# 5 = Too many requests per second
log_level = sickrage.app.log.INFO
log_level = sickrage.app.log.DEBUG
retries -= 1
elif error_code not in (8, 10, 12, 14, 20):
# 8, 10, 12, 14 = Cant find * in database. Are you sure this * exists?
# 20 = No results found
log_level = sickrage.app.log.WARNING
log_level = sickrage.app.log.DEBUG
retries = 0
elif error_code not in (2, 4):
# 2, 4 = Invalid token. Use get_token for a new one!
log_level = sickrage.app.log.WARNING
log_level = sickrage.app.log.DEBUG
retries -= 1
else:
log_level = sickrage.app.log.DEBUG
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment