Skip to content

Commit

Permalink
Merge branch 'oauthlib:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
dasm committed Jun 21, 2022
2 parents ed0cb63 + bdc486e commit f52f641
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 61 deletions.
2 changes: 1 addition & 1 deletion docs/oauth2/server.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions oauthlib/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@
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'
Expand Down
35 changes: 15 additions & 20 deletions oauthlib/oauth1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,19 @@
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)
11 changes: 5 additions & 6 deletions oauthlib/oauth1/rfc5849/endpoints/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
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:
Expand Down
3 changes: 1 addition & 2 deletions oauthlib/oauth1/rfc5849/signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,13 @@
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__)


Expand Down
8 changes: 4 additions & 4 deletions oauthlib/oauth2/rfc6749/clients/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
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
Expand Down
3 changes: 1 addition & 2 deletions oauthlib/oauth2/rfc8628/clients/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
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):
Expand Down
1 change: 0 additions & 1 deletion oauthlib/openid/connect/core/grant_types/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
ConsentRequired, InvalidRequestError, LoginRequired,
)


log = logging.getLogger(__name__)


Expand Down
4 changes: 3 additions & 1 deletion oauthlib/openid/connect/core/tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
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):
Expand Down
27 changes: 8 additions & 19 deletions tests/oauth1/rfc5849/test_signatures.py
Original file line number Diff line number Diff line change
@@ -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

# ################################################################

Expand Down
3 changes: 2 additions & 1 deletion tests/oauth2/rfc6749/endpoints/test_metadata.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
import json

from oauthlib.oauth2 import MetadataEndpoint, Server, TokenEndpoint

import json
from tests.unittest import TestCase


Expand Down

0 comments on commit f52f641

Please sign in to comment.