summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDariusz <github@smigiel.dev>2022-06-21 07:53:36 -0700
committerGitHub <noreply@github.com>2022-06-21 07:53:36 -0700
commitf52f641d763e4958d108e875e0cd6fca50d110f2 (patch)
tree62b0c653973035c88d4044105fde43a25397ef53
parented0cb63945c4a5940b185823809693b7f97989ad (diff)
parentbdc486e2bc3a188027a4ebec3a3013e64023ce62 (diff)
downloadoauthlib-f52f641d763e4958d108e875e0cd6fca50d110f2.tar.gz
Merge branch 'oauthlib:master' into master
-rw-r--r--docs/oauth2/server.rst2
-rw-r--r--oauthlib/common.py6
-rw-r--r--oauthlib/oauth1/__init__.py35
-rw-r--r--oauthlib/oauth1/rfc5849/endpoints/base.py11
-rw-r--r--oauthlib/oauth1/rfc5849/signature.py3
-rw-r--r--oauthlib/oauth2/rfc6749/clients/base.py8
-rw-r--r--oauthlib/oauth2/rfc8628/clients/device.py3
-rw-r--r--oauthlib/openid/connect/core/grant_types/base.py1
-rw-r--r--oauthlib/openid/connect/core/tokens.py4
-rw-r--r--tests/oauth1/rfc5849/test_signatures.py27
-rw-r--r--tests/oauth2/rfc6749/endpoints/test_metadata.py3
11 files changed, 42 insertions, 61 deletions
diff --git a/docs/oauth2/server.rst b/docs/oauth2/server.rst
index 15420f3..922189b 100644
--- a/docs/oauth2/server.rst
+++ b/docs/oauth2/server.rst
@@ -447,7 +447,7 @@ The example using Django but should be transferable to any framework.
response[k] = v
return response
- def response_from_error(e)
+ def response_from_error(e):
return HttpResponseBadRequest('Evil client is unable to send a proper request. Error is: ' + e.description)
diff --git a/oauthlib/common.py b/oauthlib/common.py
index b5fbf52..395e75e 100644
--- a/oauthlib/common.py
+++ b/oauthlib/common.py
@@ -18,11 +18,9 @@ from urllib.parse import (
from . import get_debug
try:
- from secrets import randbits
- from secrets import SystemRandom
+ from secrets import SystemRandom, randbits
except ImportError:
- from random import getrandbits as randbits
- from random import SystemRandom
+ from random import SystemRandom, getrandbits as randbits
UNICODE_ASCII_CHARACTER_SET = ('abcdefghijklmnopqrstuvwxyz'
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
diff --git a/oauthlib/oauth1/__init__.py b/oauthlib/oauth1/__init__.py
index 07ef422..9caf12a 100644
--- a/oauthlib/oauth1/__init__.py
+++ b/oauthlib/oauth1/__init__.py
@@ -5,24 +5,19 @@ oauthlib.oauth1
This module is a wrapper for the most recent implementation of OAuth 1.0 Client
and Server classes.
"""
-from .rfc5849 import Client
-from .rfc5849 import (SIGNATURE_HMAC,
- SIGNATURE_HMAC_SHA1,
- SIGNATURE_HMAC_SHA256,
- SIGNATURE_HMAC_SHA512,
- SIGNATURE_RSA,
- SIGNATURE_RSA_SHA1,
- SIGNATURE_RSA_SHA256,
- SIGNATURE_RSA_SHA512,
- SIGNATURE_PLAINTEXT)
-from .rfc5849 import SIGNATURE_TYPE_AUTH_HEADER, SIGNATURE_TYPE_QUERY
-from .rfc5849 import SIGNATURE_TYPE_BODY
+from .rfc5849 import (
+ SIGNATURE_HMAC, SIGNATURE_HMAC_SHA1, SIGNATURE_HMAC_SHA256,
+ SIGNATURE_HMAC_SHA512, SIGNATURE_PLAINTEXT, SIGNATURE_RSA,
+ SIGNATURE_RSA_SHA1, SIGNATURE_RSA_SHA256, SIGNATURE_RSA_SHA512,
+ SIGNATURE_TYPE_AUTH_HEADER, SIGNATURE_TYPE_BODY, SIGNATURE_TYPE_QUERY,
+ Client,
+)
+from .rfc5849.endpoints import (
+ AccessTokenEndpoint, AuthorizationEndpoint, RequestTokenEndpoint,
+ ResourceEndpoint, SignatureOnlyEndpoint, WebApplicationServer,
+)
+from .rfc5849.errors import (
+ InsecureTransportError, InvalidClientError, InvalidRequestError,
+ InvalidSignatureMethodError, OAuth1Error,
+)
from .rfc5849.request_validator import RequestValidator
-from .rfc5849.endpoints import RequestTokenEndpoint, AuthorizationEndpoint
-from .rfc5849.endpoints import AccessTokenEndpoint, ResourceEndpoint
-from .rfc5849.endpoints import SignatureOnlyEndpoint, WebApplicationServer
-from .rfc5849.errors import (InsecureTransportError,
- InvalidClientError,
- InvalidRequestError,
- InvalidSignatureMethodError,
- OAuth1Error)
diff --git a/oauthlib/oauth1/rfc5849/endpoints/base.py b/oauthlib/oauth1/rfc5849/endpoints/base.py
index 3a8c267..7831be7 100644
--- a/oauthlib/oauth1/rfc5849/endpoints/base.py
+++ b/oauthlib/oauth1/rfc5849/endpoints/base.py
@@ -11,12 +11,11 @@ import time
from oauthlib.common import CaseInsensitiveDict, Request, generate_token
from .. import (
- CONTENT_TYPE_FORM_URLENCODED,
- SIGNATURE_HMAC_SHA1, SIGNATURE_HMAC_SHA256, SIGNATURE_HMAC_SHA512,
- SIGNATURE_RSA_SHA1, SIGNATURE_RSA_SHA256, SIGNATURE_RSA_SHA512,
- SIGNATURE_PLAINTEXT,
- SIGNATURE_TYPE_AUTH_HEADER, SIGNATURE_TYPE_BODY,
- SIGNATURE_TYPE_QUERY, errors, signature, utils)
+ CONTENT_TYPE_FORM_URLENCODED, SIGNATURE_HMAC_SHA1, SIGNATURE_HMAC_SHA256,
+ SIGNATURE_HMAC_SHA512, SIGNATURE_PLAINTEXT, SIGNATURE_RSA_SHA1,
+ SIGNATURE_RSA_SHA256, SIGNATURE_RSA_SHA512, SIGNATURE_TYPE_AUTH_HEADER,
+ SIGNATURE_TYPE_BODY, SIGNATURE_TYPE_QUERY, errors, signature, utils,
+)
class BaseEndpoint:
diff --git a/oauthlib/oauth1/rfc5849/signature.py b/oauthlib/oauth1/rfc5849/signature.py
index 7e8044a..862c3f3 100644
--- a/oauthlib/oauth1/rfc5849/signature.py
+++ b/oauthlib/oauth1/rfc5849/signature.py
@@ -39,14 +39,13 @@ import hashlib
import hmac
import ipaddress
import logging
+import urllib.parse as urlparse
import warnings
from oauthlib.common import extract_params, safe_string_equals, urldecode
-import urllib.parse as urlparse
from . import utils
-
log = logging.getLogger(__name__)
diff --git a/oauthlib/oauth2/rfc6749/clients/base.py b/oauthlib/oauth2/rfc6749/clients/base.py
index 6a5d0dc..0dbf1c0 100644
--- a/oauthlib/oauth2/rfc6749/clients/base.py
+++ b/oauthlib/oauth2/rfc6749/clients/base.py
@@ -6,12 +6,12 @@ oauthlib.oauth2.rfc6749
This module is an implementation of various logic needed
for consuming OAuth 2.0 RFC6749.
"""
+import base64
+import hashlib
+import re
+import secrets
import time
import warnings
-import secrets
-import re
-import hashlib
-import base64
from oauthlib.common import generate_token
from oauthlib.oauth2.rfc6749 import tokens
diff --git a/oauthlib/oauth2/rfc8628/clients/device.py b/oauthlib/oauth2/rfc8628/clients/device.py
index 4707cc5..b9ba215 100644
--- a/oauthlib/oauth2/rfc8628/clients/device.py
+++ b/oauthlib/oauth2/rfc8628/clients/device.py
@@ -5,12 +5,11 @@ oauthlib.oauth2.rfc8628
This module is an implementation of various logic needed
for consuming and providing OAuth 2.0 Device Authorization RFC8628.
"""
-
+from oauthlib.common import add_params_to_uri
from oauthlib.oauth2 import BackendApplicationClient, Client
from oauthlib.oauth2.rfc6749.errors import InsecureTransportError
from oauthlib.oauth2.rfc6749.parameters import prepare_token_request
from oauthlib.oauth2.rfc6749.utils import is_secure_transport, list_to_scope
-from oauthlib.common import add_params_to_uri
class DeviceClient(Client):
diff --git a/oauthlib/openid/connect/core/grant_types/base.py b/oauthlib/openid/connect/core/grant_types/base.py
index 76173e6..33411da 100644
--- a/oauthlib/openid/connect/core/grant_types/base.py
+++ b/oauthlib/openid/connect/core/grant_types/base.py
@@ -8,7 +8,6 @@ from oauthlib.oauth2.rfc6749.errors import (
ConsentRequired, InvalidRequestError, LoginRequired,
)
-
log = logging.getLogger(__name__)
diff --git a/oauthlib/openid/connect/core/tokens.py b/oauthlib/openid/connect/core/tokens.py
index a312e2d..936ab52 100644
--- a/oauthlib/openid/connect/core/tokens.py
+++ b/oauthlib/openid/connect/core/tokens.py
@@ -4,7 +4,9 @@ authlib.openid.connect.core.tokens
This module contains methods for adding JWT tokens to requests.
"""
-from oauthlib.oauth2.rfc6749.tokens import TokenBase, random_token_generator, get_token_from_header
+from oauthlib.oauth2.rfc6749.tokens import (
+ TokenBase, get_token_from_header, random_token_generator,
+)
class JWTToken(TokenBase):
diff --git a/tests/oauth1/rfc5849/test_signatures.py b/tests/oauth1/rfc5849/test_signatures.py
index e737e68..f0e1809 100644
--- a/tests/oauth1/rfc5849/test_signatures.py
+++ b/tests/oauth1/rfc5849/test_signatures.py
@@ -1,26 +1,15 @@
# -*- coding: utf-8 -*-
from oauthlib.oauth1.rfc5849.signature import (
- collect_parameters,
- signature_base_string,
- base_string_uri,
- normalize_parameters,
- sign_hmac_sha1_with_client,
- sign_hmac_sha256_with_client,
- sign_hmac_sha512_with_client,
- sign_rsa_sha1_with_client,
- sign_rsa_sha256_with_client,
- sign_rsa_sha512_with_client,
- sign_plaintext_with_client,
- verify_hmac_sha1,
- verify_hmac_sha256,
- verify_hmac_sha512,
- verify_rsa_sha1,
- verify_rsa_sha256,
- verify_rsa_sha512,
- verify_plaintext
+ base_string_uri, collect_parameters, normalize_parameters,
+ sign_hmac_sha1_with_client, sign_hmac_sha256_with_client,
+ sign_hmac_sha512_with_client, sign_plaintext_with_client,
+ sign_rsa_sha1_with_client, sign_rsa_sha256_with_client,
+ sign_rsa_sha512_with_client, signature_base_string, verify_hmac_sha1,
+ verify_hmac_sha256, verify_hmac_sha512, verify_plaintext, verify_rsa_sha1,
+ verify_rsa_sha256, verify_rsa_sha512,
)
-from tests.unittest import TestCase
+from tests.unittest import TestCase
# ################################################################
diff --git a/tests/oauth2/rfc6749/endpoints/test_metadata.py b/tests/oauth2/rfc6749/endpoints/test_metadata.py
index 22cf4ba..1f5b912 100644
--- a/tests/oauth2/rfc6749/endpoints/test_metadata.py
+++ b/tests/oauth2/rfc6749/endpoints/test_metadata.py
@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
+import json
+
from oauthlib.oauth2 import MetadataEndpoint, Server, TokenEndpoint
-import json
from tests.unittest import TestCase