From 491d9aab889db562c185ca9477560f1991dab2dc Mon Sep 17 00:00:00 2001 From: Tomas Pazderka Date: Fri, 2 Aug 2019 16:20:59 +0200 Subject: [PATCH] Removed deprecated message factory --- CHANGELOG.md | 2 ++ src/oic/extension/message.py | 29 ------------------- src/oic/oauth2/message.py | 30 ------------------- src/oic/oic/message.py | 56 +----------------------------------- 4 files changed, 3 insertions(+), 114 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ba23e209..cecd4cace 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,10 +13,12 @@ The format is based on the [KeepAChangeLog] project. ### Removed - [#671] Removed deprecated request/response_cls kwargs from Provider/Client methods - [#677] Removed more deprecated code +- [#676] Removed deprecated message factory and related stuff [#671]: https://github.com/OpenIDC/pyoidc/pull/671 [#677]: https://github.com/OpenIDC/pyoidc/pull/677 [#602]: https://github.com/OpenIDC/pyoidc/issues/602 +[#676]: https://github.com/OpenIDC/pyoidc/pull/676 ## 1.0.1 [2019-06-30] diff --git a/src/oic/extension/message.py b/src/oic/extension/message.py index 759d658f9..6ddbdf0ee 100644 --- a/src/oic/extension/message.py +++ b/src/oic/extension/message.py @@ -1,5 +1,4 @@ import inspect -import sys from urllib.parse import urlparse import requests @@ -190,34 +189,6 @@ class ClientUpdateRequest(RegistrationRequest): ) -MSG = { - "RegistrationRequest": RegistrationRequest, - "ClientInfoResponse": ClientInfoResponse, - "ClientRegistrationError": ClientRegistrationError, - "ClientUpdateRequest": ClientUpdateRequest, - "TokenRevocationRequest": TokenRevocationRequest, - "TokenIntrospectionRequest": TokenIntrospectionRequest, - "TokenIntrospectionResponse": TokenIntrospectionResponse, - "SoftwareStatement": SoftwareStatement, - "StateJWT": StateJWT, -} - - -def factory(msgtype): - for _, obj in inspect.getmembers(sys.modules[__name__]): - if inspect.isclass(obj) and issubclass(obj, Message): - try: - if obj.__name__ == msgtype: - return obj - except AttributeError: - pass - - # check among standard OAuth2 messages - from oic.oauth2 import message - - return message.factory(msgtype) - - def make_software_statement(keyjar, iss, **kwargs): params = list(inspect.signature(JWT.__init__).parameters.keys()) diff --git a/src/oic/oauth2/message.py b/src/oic/oauth2/message.py index 7e21764f8..1e434d473 100644 --- a/src/oic/oauth2/message.py +++ b/src/oic/oauth2/message.py @@ -1,7 +1,6 @@ import copy import json import logging -import warnings from collections import MutableMapping from collections import namedtuple from json import JSONDecodeError @@ -1154,35 +1153,6 @@ class ASConfigurationResponse(Message): c_default = {"version": "3.0"} -MSG = { - "Message": Message, - "ErrorResponse": ErrorResponse, - "AuthorizationErrorResponse": AuthorizationErrorResponse, - "TokenErrorResponse": TokenErrorResponse, - "AccessTokenRequest": AccessTokenRequest, - "AuthorizationRequest": AuthorizationRequest, - "AuthorizationResponse": AuthorizationResponse, - "AccessTokenResponse": AccessTokenResponse, - "NoneResponse": NoneResponse, - "ROPCAccessTokenRequest": ROPCAccessTokenRequest, - "CCAccessTokenRequest": CCAccessTokenRequest, - "RefreshAccessTokenRequest": RefreshAccessTokenRequest, - "ResourceRequest": ResourceRequest, - "ASConfigurationResponse": ASConfigurationResponse, -} - - -def factory(msgtype): - warnings.warn( - "`factory` is deprecated. Use `OauthMessageFactory` instead.", - DeprecationWarning, - ) - try: - return MSG[msgtype] - except KeyError: - raise FormatError("Unknown message type: %s" % msgtype) - - MessageTuple = namedtuple("MessageTuple", ["request_cls", "response_cls"]) diff --git a/src/oic/oic/message.py b/src/oic/oic/message.py index 420e545cf..6c11690f9 100644 --- a/src/oic/oic/message.py +++ b/src/oic/oic/message.py @@ -1,9 +1,6 @@ -import inspect import json import logging -import sys import time -import warnings from typing import Dict # noqa from typing import List # noqa from urllib.parse import urlencode @@ -1120,58 +1117,6 @@ class FrontChannelLogoutRequest(Message): c_param = {"iss": SINGLE_OPTIONAL_STRING, "sid": SINGLE_OPTIONAL_STRING} -MSG = { - "RefreshAccessTokenRequest": RefreshAccessTokenRequest, - "TokenErrorResponse": TokenErrorResponse, - "AccessTokenResponse": AccessTokenResponse, - "UserInfoRequest": UserInfoRequest, - "AuthorizationResponse": AuthorizationResponse, - "AuthorizationErrorResponse": AuthorizationErrorResponse, - "AuthorizationRequest": AuthorizationRequest, - "AccessTokenRequest": AccessTokenRequest, - "AddressClaim": AddressClaim, - "OpenIDSchema": OpenIDSchema, - "RegistrationRequest": RegistrationRequest, - "RegistrationResponse": RegistrationResponse, - "ClientRegistrationErrorResponse": ClientRegistrationErrorResponse, - "IdToken": IdToken, - "RefreshSessionRequest": RefreshSessionRequest, - "RefreshSessionResponse": RefreshSessionResponse, - "CheckSessionRequest": CheckSessionRequest, - "CheckIDRequest": CheckIDRequest, - "EndSessionRequest": EndSessionRequest, - "EndSessionResponse": EndSessionResponse, - "Claims": Claims, - "OpenIDRequest": OpenIDRequest, - "ProviderConfigurationResponse": ProviderConfigurationResponse, - "AuthnToken": AuthnToken, - "UserInfoErrorResponse": UserInfoErrorResponse, - "DiscoveryRequest": DiscoveryRequest, - "DiscoveryResponse": DiscoveryResponse, - "ResourceRequest": ResourceRequest, - # LOGOUT messages - "LogoutToken": LogoutToken, - "BackChannelLogoutRequest": BackChannelLogoutRequest, - "FrontChannelLogoutRequest": FrontChannelLogoutRequest, -} - - -def factory(msgtype): - warnings.warn( - "`factory` is deprecated. Use `OIDCMessageFactory` instead.", DeprecationWarning - ) - for _, obj in inspect.getmembers(sys.modules[__name__]): - if inspect.isclass(obj) and issubclass(obj, Message): - try: - if obj.__name__ == msgtype: - return obj - except AttributeError: - pass - - # Fall back to basic OAuth2 messages - return message.factory(msgtype) - - class OIDCMessageFactory(MessageFactory): """Factory that knows OIDC message types.""" @@ -1183,6 +1128,7 @@ class OIDCMessageFactory(MessageFactory): userinfo_endpoint = MessageTuple(UserInfoRequest, Message) registration_endpoint = MessageTuple(RegistrationRequest, RegistrationResponse) + read_endpoint = MessageTuple(Message, RegistrationResponse) endsession_endpoint = MessageTuple(EndSessionRequest, EndSessionResponse) checkid_endpoint = MessageTuple(CheckIDRequest, IdToken) checksession_endpoint = MessageTuple(CheckSessionRequest, IdToken)