Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed deprecated message factory #676

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ The format is based on the [KeepAChangeLog] project.
### Added
- [#739] Better error message for providers which return HTTP Error 405 on userinfo

[#739] https://github.com/OpenIDC/pyoidc/pull/739/
### Removed
- [#676] Removed deprecated message factory and related stuff

[#676]: https://github.com/OpenIDC/pyoidc/pull/676
[#739]: https://github.com/OpenIDC/pyoidc/pull/739/

## 1.2.0 [2020-02-05]

Expand Down
29 changes: 0 additions & 29 deletions src/oic/extension/message.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import inspect
import sys
from urllib.parse import urlparse

import requests
Expand Down Expand Up @@ -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())

Expand Down
30 changes: 0 additions & 30 deletions src/oic/oauth2/message.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import copy
import json
import logging
import warnings
from collections import namedtuple
from collections.abc import MutableMapping
from json import JSONDecodeError
Expand Down Expand Up @@ -1160,35 +1159,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"])


Expand Down
56 changes: 1 addition & 55 deletions src/oic/oic/message.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -1123,58 +1120,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."""

Expand All @@ -1186,6 +1131,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)
Expand Down