From 59c3851264ab78df8826c05e55e54a7e9e3ddb14 Mon Sep 17 00:00:00 2001 From: domste Date: Thu, 27 Aug 2020 14:25:00 +0200 Subject: [PATCH] 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)