Skip to content

Commit

Permalink
Ran black and isort.
Browse files Browse the repository at this point in the history
  • Loading branch information
rohe committed Oct 19, 2023
1 parent fa52186 commit 5fca1e2
Show file tree
Hide file tree
Showing 88 changed files with 836 additions and 865 deletions.
3 changes: 1 addition & 2 deletions src/idpyoidc/claims.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def handle_keys(self, configuration: dict, keyjar: Optional[KeyJar] = None):
return {"keyjar": keyjar, "jwks": _jwks, "jwks_uri": _jwks_uri}

def load_conf(
self, configuration: dict, supports: dict, keyjar: Optional[KeyJar] = None
self, configuration: dict, supports: dict, keyjar: Optional[KeyJar] = None
) -> KeyJar:
for attr, val in configuration.items():
if attr in ["preference", "capabilities"]:
Expand Down Expand Up @@ -212,4 +212,3 @@ def get_claim(self, key, default=None):
return default
else:
return _val

4 changes: 2 additions & 2 deletions src/idpyoidc/client/claims/oidc.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ def __init__(self, prefer: Optional[dict] = None, callback_path: Optional[dict]

def verify_rules(self, supports):
if self.get_preference("request_parameter_supported") and self.get_preference(
"request_uri_parameter_supported"
"request_uri_parameter_supported"
):
raise ValueError(
"You have to chose one of 'request_parameter_supported' and "
"'request_uri_parameter_supported'. You can't have both."
)

if self.get_preference("request_parameter_supported") or self.get_preference(
"request_uri_parameter_supported"
"request_uri_parameter_supported"
):
if not self.get_preference("request_object_signing_alg_values_supported"):
self.set_preference(
Expand Down
5 changes: 3 additions & 2 deletions src/idpyoidc/client/client_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@

from idpyoidc.defaults import DEF_SIGN_ALG
from idpyoidc.defaults import JWT_BEARER
from idpyoidc.message.oauth2 import AccessTokenRequest
from idpyoidc.message.oauth2 import SINGLE_OPTIONAL_STRING
from idpyoidc.message.oauth2 import AccessTokenRequest
from idpyoidc.message.oidc import AuthnToken
from idpyoidc.time_util import utc_time_sans_frac
from idpyoidc.util import rndstr
from .util import sanitize

from ..message import VREQUIRED
from ..util import instantiate
from .util import sanitize

# from idpyoidc.oidc.backchannel_authentication import ClientNotificationAuthn

Expand Down
1 change: 1 addition & 0 deletions src/idpyoidc/client/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from idpyoidc.configure import Base
from idpyoidc.logging import configure_logging

from .util import lower_or_upper

try:
Expand Down
2 changes: 1 addition & 1 deletion src/idpyoidc/client/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def __init__(
keyjar=self.keyjar,
upstream_get=self.unit_get,
client_type=client_type,
entity_id=self.entity_id
entity_id=self.entity_id,
)

self.setup_client_authn_methods(config)
Expand Down
2 changes: 1 addition & 1 deletion src/idpyoidc/client/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
from http.cookies import CookieError
from http.cookies import SimpleCookie

from requests import request
from idpyoidc.client.exception import NonFatalException
from idpyoidc.client.util import sanitize
from idpyoidc.client.util import set_cookie
from requests import request

__author__ = "roland"

Expand Down
88 changes: 44 additions & 44 deletions src/idpyoidc/client/oauth2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
from typing import Union

from cryptojwt.key_jar import KeyJar
from requests import request

from idpyoidc.client.entity import Entity
from idpyoidc.client.exception import ConfigurationError
from idpyoidc.client.exception import OidcServiceError
from idpyoidc.client.exception import ParseError
from idpyoidc.client.service import REQUEST_INFO
from idpyoidc.client.service import Service
from idpyoidc.client.service import SUCCESSFUL
from idpyoidc.client.service import Service
from idpyoidc.client.util import do_add_ons
from idpyoidc.client.util import get_deserialization_method
from idpyoidc.configure import Configuration
from idpyoidc.context import OidcContext
from idpyoidc.exception import FormatError
from idpyoidc.message import Message
from idpyoidc.message.oauth2 import is_error_message
from requests import request

__author__ = "Roland Hedberg"

Expand All @@ -38,20 +38,20 @@ class Client(Entity):
client_type = "oauth2"

def __init__(
self,
keyjar: Optional[KeyJar] = None,
config: Optional[Union[dict, Configuration]] = None,
services: Optional[dict] = None,
httpc: Optional[Callable] = None,
httpc_params: Optional[dict] = None,
context: Optional[OidcContext] = None,
upstream_get: Optional[Callable] = None,
key_conf: Optional[dict] = None,
entity_id: Optional[str] = "",
verify_ssl: Optional[bool] = True,
jwks_uri: Optional[str] = "",
client_type: Optional[str] = "",
**kwargs
self,
keyjar: Optional[KeyJar] = None,
config: Optional[Union[dict, Configuration]] = None,
services: Optional[dict] = None,
httpc: Optional[Callable] = None,
httpc_params: Optional[dict] = None,
context: Optional[OidcContext] = None,
upstream_get: Optional[Callable] = None,
key_conf: Optional[dict] = None,
entity_id: Optional[str] = "",
verify_ssl: Optional[bool] = True,
jwks_uri: Optional[str] = "",
client_type: Optional[str] = "",
**kwargs
):
"""
Expand All @@ -73,7 +73,7 @@ def __init__(

if client_type:
self.client_type = client_type
elif config and 'client_type' in config:
elif config and "client_type" in config:
client_type = self.client_type = config["client_type"]
else:
client_type = self.client_type
Expand All @@ -85,7 +85,7 @@ def __init__(
else:
httpc_params = {"verify": False}

jwks_uri = jwks_uri or config.get('jwks_uri', '')
jwks_uri = jwks_uri or config.get("jwks_uri", "")

Entity.__init__(
self,
Expand Down Expand Up @@ -113,12 +113,12 @@ def __init__(
do_add_ons(_add_ons, self._service)

def do_request(
self,
request_type: str,
response_body_type: Optional[str] = "",
request_args: Optional[dict] = None,
behaviour_args: Optional[dict] = None,
**kwargs
self,
request_type: str,
response_body_type: Optional[str] = "",
request_args: Optional[dict] = None,
behaviour_args: Optional[dict] = None,
**kwargs
):
_srv = self._service[request_type]

Expand All @@ -141,14 +141,14 @@ def set_client_id(self, client_id):
self.get_context().set("client_id", client_id)

def get_response(
self,
service: Service,
url: str,
method: Optional[str] = "GET",
body: Optional[dict] = None,
response_body_type: Optional[str] = "",
headers: Optional[dict] = None,
**kwargs
self,
service: Service,
url: str,
method: Optional[str] = "GET",
body: Optional[dict] = None,
response_body_type: Optional[str] = "",
headers: Optional[dict] = None,
**kwargs
):
"""
Expand Down Expand Up @@ -184,14 +184,14 @@ def get_response(
return self.parse_request_response(service, resp, response_body_type, **kwargs)

def service_request(
self,
service: Service,
url: str,
method: Optional[str] = "GET",
body: Optional[dict] = None,
response_body_type: Optional[str] = "",
headers: Optional[dict] = None,
**kwargs
self,
service: Service,
url: str,
method: Optional[str] = "GET",
body: Optional[dict] = None,
response_body_type: Optional[str] = "",
headers: Optional[dict] = None,
**kwargs
) -> Message:
"""
The method that sends the request and handles the response returned.
Expand Down Expand Up @@ -320,10 +320,10 @@ def dynamic_provider_info_discovery(client: Client, behaviour_args: Optional[dic
:param client: A :py:class:`idpyoidc.client.oidc.Client` instance
"""

if client.client_type == 'oidc' and client.get_service("provider_info"):
service = 'provider_info'
elif client.client_type == 'oauth2' and client.get_service('server_metadata'):
service = 'server_metadata'
if client.client_type == "oidc" and client.get_service("provider_info"):
service = "provider_info"
elif client.client_type == "oauth2" and client.get_service("server_metadata"):
service = "server_metadata"
else:
raise ConfigurationError("Can not do dynamic provider info discovery")

Expand Down
2 changes: 1 addition & 1 deletion src/idpyoidc/client/oauth2/access_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from idpyoidc.client.service import Service
from idpyoidc.message import oauth2
from idpyoidc.message.oauth2 import ResponseMessage
from idpyoidc.time_util import time_sans_frac
from idpyoidc.metadata import get_signing_algs
from idpyoidc.time_util import time_sans_frac

LOGGER = logging.getLogger(__name__)

Expand Down
18 changes: 9 additions & 9 deletions src/idpyoidc/client/oauth2/add_on/dpop.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
from typing import Optional

from cryptojwt.jwk.jwk import key_from_jwk_dict
from cryptojwt.jws.jws import factory
from cryptojwt.jws.jws import JWS
from cryptojwt.jws.jws import factory
from cryptojwt.key_bundle import key_by_alg

from idpyoidc.client.service_context import ServiceContext
from idpyoidc.message import Message
from idpyoidc.message import SINGLE_OPTIONAL_STRING
from idpyoidc.message import SINGLE_REQUIRED_INT
from idpyoidc.message import SINGLE_REQUIRED_JSON
from idpyoidc.message import SINGLE_REQUIRED_STRING
from idpyoidc.message import Message
from idpyoidc.metadata import get_signing_algs
from idpyoidc.time_util import utc_time_sans_frac

Expand Down Expand Up @@ -91,13 +91,13 @@ def verify_header(self, dpop_header) -> Optional["DPoPProof"]:


def dpop_header(
service_context: ServiceContext,
service_endpoint: str,
http_method: str,
headers: Optional[dict] = None,
token: Optional[str] = "",
nonce: Optional[str] = "",
**kwargs
service_context: ServiceContext,
service_endpoint: str,
http_method: str,
headers: Optional[dict] = None,
token: Optional[str] = "",
nonce: Optional[str] = "",
**kwargs
) -> dict:
"""
Expand Down
3 changes: 1 addition & 2 deletions src/idpyoidc/client/oauth2/add_on/jar.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import logging
from typing import Optional

from idpyoidc import metadata

from idpyoidc import claims
from idpyoidc import metadata
from idpyoidc.client.oidc.utils import construct_request_uri
from idpyoidc.client.oidc.utils import request_object_encryption
from idpyoidc.message.oidc import make_openid_request
Expand Down
2 changes: 1 addition & 1 deletion src/idpyoidc/client/oauth2/add_on/par.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

from cryptojwt import JWT
from cryptojwt.utils import importer
from requests import request

from idpyoidc.client.client_auth import CLIENT_AUTHN_METHOD
from idpyoidc.message import Message
from idpyoidc.message.oauth2 import JWTSecuredAuthorizationRequest
from idpyoidc.util import instantiate
from requests import request

logger = logging.getLogger(__name__)

Expand Down
8 changes: 4 additions & 4 deletions src/idpyoidc/client/oauth2/authorization.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ def _do_flow(self, flow_type, response_types, context) -> str:
elif flow_type == "fragment":
if implicit_response_types(response_types):
return "fragment"
elif flow_type == 'form_post':
rm = context.get_preference('response_modes_supported')
if rm and 'form_post' in rm:
elif flow_type == "form_post":
rm = context.get_preference("response_modes_supported")
if rm and "form_post" in rm:
if context.config.conf.get("separate_form_post_cb", True):
return "form_post"
else:
return "query"
return ''
return ""

def _do_redirect_uris(self, base_url, hex, context, callback_uris, response_types):
_redirect_uris = context.get_preference("redirect_uris", [])
Expand Down
Loading

0 comments on commit 5fca1e2

Please sign in to comment.