From 59c3851264ab78df8826c05e55e54a7e9e3ddb14 Mon Sep 17 00:00:00 2001 From: domste Date: Thu, 27 Aug 2020 14:25:00 +0200 Subject: [PATCH 1/2] add deprecation exception on entitlement call --- keycloak/keycloak_openid.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/keycloak/keycloak_openid.py b/keycloak/keycloak_openid.py index 9ab42f0..b4d60fd 100644 --- a/keycloak/keycloak_openid.py +++ b/keycloak/keycloak_openid.py @@ -28,7 +28,8 @@ from jose import jwt from .authorization import Authorization from .connection import ConnectionManager from .exceptions import raise_error_from_response, KeycloakGetError, \ - KeycloakRPTNotFound, KeycloakAuthorizationConfigError, KeycloakInvalidTokenError + KeycloakRPTNotFound, KeycloakAuthorizationConfigError, KeycloakInvalidTokenError, + KeycloakDeprecationError from .urls_patterns import ( URL_REALM, URL_AUTH, @@ -291,6 +292,9 @@ class KeycloakOpenID: self.connection.add_param_headers("Authorization", "Bearer " + token) params_path = {"realm-name": self.realm_name, "resource-server-id": resource_server_id} data_raw = self.connection.raw_get(URL_ENTITLEMENT.format(**params_path)) + + if data_raw.status_code == 404: + return raise_error_from_response(data_raw, KeycloakDeprecationError) return raise_error_from_response(data_raw, KeycloakGetError) From 4da5bed75e27703d160443b7181e22a29c2d72bb Mon Sep 17 00:00:00 2001 From: domste Date: Thu, 27 Aug 2020 14:27:16 +0200 Subject: [PATCH 2/2] added KeycloakDeprecationException add exception to indicate a deprecation case --- keycloak/exceptions.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/keycloak/exceptions.py b/keycloak/exceptions.py index 381d9af..67da62a 100644 --- a/keycloak/exceptions.py +++ b/keycloak/exceptions.py @@ -53,6 +53,9 @@ class KeycloakOperationError(KeycloakError): pass +class KeycloakDeprecationError(KeycloakError): + pass + class KeycloakGetError(KeycloakOperationError): pass