Skip to content

Commit 6ed6058

Browse files
committed
Apply ruff format
1 parent 6084ff1 commit 6ed6058

File tree

4 files changed

+55
-63
lines changed

4 files changed

+55
-63
lines changed

oauthlib/oauth2/rfc8628/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
This module is an implementation of various logic needed
66
for consuming and providing OAuth 2.0 Device Authorization RFC8628.
77
"""
8+
89
import logging
910
from .pre_configured import DeviceApplicationServer
1011

oauthlib/oauth2/rfc8628/endpoints/device_authorization.py

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,22 @@
55
This module is an implementation of various logic needed
66
for consuming and providing OAuth 2.0 RFC8628.
77
"""
8+
89
import json
910
import logging
1011
from typing import Callable
1112

1213
from oauthlib.common import Request, generate_token
1314
from oauthlib.oauth2.rfc6749 import errors
1415
from oauthlib.oauth2.rfc6749.endpoints.base import (
15-
BaseEndpoint, catch_errors_and_unavailability,
16+
BaseEndpoint,
17+
catch_errors_and_unavailability,
1618
)
1719

1820
log = logging.getLogger(__name__)
1921

2022

2123
class DeviceAuthorizationEndpoint(BaseEndpoint):
22-
2324
"""DeviceAuthorization endpoint - used by the client to initiate
2425
the authorization flow by requesting a set of verification codes
2526
from the authorization server by making an HTTP "POST" request to
@@ -33,15 +34,7 @@ class DeviceAuthorizationEndpoint(BaseEndpoint):
3334
themselves.
3435
"""
3536

36-
def __init__(
37-
self,
38-
request_validator,
39-
verification_uri,
40-
expires_in=1800,
41-
interval=None,
42-
verification_uri_complete=None,
43-
user_code_generator: Callable[[None], str] = None
44-
):
37+
def __init__(self, request_validator, verification_uri, expires_in=1800, interval=None, verification_uri_complete=None, user_code_generator: Callable[[None], str] = None):
4538
"""
4639
:param request_validator: An instance of RequestValidator.
4740
:type request_validator: oauthlib.oauth2.rfc6749.RequestValidator.
@@ -106,13 +99,9 @@ def validate_device_authorization_request(self, request):
10699
try:
107100
duplicate_params = request.duplicate_params
108101
except ValueError:
109-
raise errors.InvalidRequestFatalError(
110-
description="Unable to parse query string", request=request
111-
)
102+
raise errors.InvalidRequestFatalError(description="Unable to parse query string", request=request)
112103
if param in duplicate_params:
113-
raise errors.InvalidRequestFatalError(
114-
description="Duplicate %s parameter." % param, request=request
115-
)
104+
raise errors.InvalidRequestFatalError(description="Duplicate %s parameter." % param, request=request)
116105

117106
# the "application/x-www-form-urlencoded" format, per Appendix B of [RFC6749]
118107
# https://www.rfc-editor.org/rfc/rfc6749#appendix-B
@@ -140,9 +129,7 @@ def validate_device_authorization_request(self, request):
140129
self._raise_on_invalid_client(request)
141130

142131
@catch_errors_and_unavailability
143-
def create_device_authorization_response(
144-
self, uri, http_method="POST", body=None, headers=None
145-
):
132+
def create_device_authorization_response(self, uri, http_method="POST", body=None, headers=None):
146133
"""create_device_authorization_response - generates a unique device
147134
verification code and an end-user code that are valid for a limited
148135
time and includes them in the HTTP response body using the

oauthlib/oauth2/rfc8628/pre_configured.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66

77
class DeviceApplicationServer(DeviceAuthorizationEndpoint):
8-
98
"""An all-in-one endpoint featuring Authorization code grant and Bearer tokens."""
109

1110
def __init__(self, request_validator, verification_uri, user_code_generator: Callable[[None], str] = None, **kwargs):
@@ -16,6 +15,4 @@ def __init__(self, request_validator, verification_uri, user_code_generator: Cal
1615
:param verification_uri: the verification_uri to be send back.
1716
:param user_code_generator: a callable that allows the user code to be configured.
1817
"""
19-
DeviceAuthorizationEndpoint.__init__(
20-
self, request_validator, verification_uri=verification_uri, user_code_generator=user_code_generator
21-
)
18+
DeviceAuthorizationEndpoint.__init__(self, request_validator, verification_uri=verification_uri, user_code_generator=user_code_generator)

oauthlib/openid/connect/core/endpoints/pre_configured.py

Lines changed: 46 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,42 @@
55
This module is an implementation of various endpoints needed
66
for providing OpenID Connect servers.
77
"""
8+
89
from oauthlib.oauth2.rfc6749.endpoints import (
9-
AuthorizationEndpoint, IntrospectEndpoint, ResourceEndpoint,
10-
RevocationEndpoint, TokenEndpoint,
10+
AuthorizationEndpoint,
11+
IntrospectEndpoint,
12+
ResourceEndpoint,
13+
RevocationEndpoint,
14+
TokenEndpoint,
1115
)
1216
from oauthlib.oauth2.rfc6749.grant_types import (
1317
AuthorizationCodeGrant as OAuth2AuthorizationCodeGrant,
14-
ClientCredentialsGrant, ImplicitGrant as OAuth2ImplicitGrant,
18+
ClientCredentialsGrant,
19+
ImplicitGrant as OAuth2ImplicitGrant,
1520
ResourceOwnerPasswordCredentialsGrant,
1621
)
1722
from oauthlib.oauth2.rfc6749.tokens import BearerToken
1823
from oauthlib.oauth2.rfc8628.endpoints import DeviceAuthorizationEndpoint
1924

2025
from ..grant_types import (
21-
AuthorizationCodeGrant, HybridGrant, ImplicitGrant, RefreshTokenGrant,
26+
AuthorizationCodeGrant,
27+
HybridGrant,
28+
ImplicitGrant,
29+
RefreshTokenGrant,
2230
)
2331
from ..grant_types.dispatchers import (
24-
AuthorizationCodeGrantDispatcher, AuthorizationTokenGrantDispatcher,
32+
AuthorizationCodeGrantDispatcher,
33+
AuthorizationTokenGrantDispatcher,
2534
ImplicitTokenGrantDispatcher,
2635
)
2736
from ..tokens import JWTToken
2837
from .userinfo import UserInfoEndpoint
2938

3039

31-
class Server(AuthorizationEndpoint, IntrospectEndpoint, TokenEndpoint,
32-
ResourceEndpoint, RevocationEndpoint, UserInfoEndpoint):
33-
40+
class Server(AuthorizationEndpoint, IntrospectEndpoint, TokenEndpoint, ResourceEndpoint, RevocationEndpoint, UserInfoEndpoint):
3441
"""An all-in-one endpoint featuring all four major grant types."""
3542

36-
def __init__(self, request_validator, token_expires_in=None,
37-
token_generator=None, refresh_token_generator=None,
38-
*args, **kwargs):
43+
def __init__(self, request_validator, token_expires_in=None, token_generator=None, refresh_token_generator=None, *args, **kwargs):
3944
"""Construct a new all-grants-in-one server.
4045
4146
:param request_validator: An implementation of
@@ -51,50 +56,52 @@ def __init__(self, request_validator, token_expires_in=None,
5156
"""
5257
self.auth_grant = OAuth2AuthorizationCodeGrant(request_validator)
5358
self.implicit_grant = OAuth2ImplicitGrant(request_validator)
54-
self.password_grant = ResourceOwnerPasswordCredentialsGrant(
55-
request_validator)
59+
self.password_grant = ResourceOwnerPasswordCredentialsGrant(request_validator)
5660
self.credentials_grant = ClientCredentialsGrant(request_validator)
5761
self.refresh_grant = RefreshTokenGrant(request_validator)
5862
self.openid_connect_auth = AuthorizationCodeGrant(request_validator)
5963
self.openid_connect_implicit = ImplicitGrant(request_validator)
6064
self.openid_connect_hybrid = HybridGrant(request_validator)
6165

62-
self.bearer = BearerToken(request_validator, token_generator,
63-
token_expires_in, refresh_token_generator)
66+
self.bearer = BearerToken(request_validator, token_generator, token_expires_in, refresh_token_generator)
6467

65-
self.jwt = JWTToken(request_validator, token_generator,
66-
token_expires_in, refresh_token_generator)
68+
self.jwt = JWTToken(request_validator, token_generator, token_expires_in, refresh_token_generator)
6769

6870
self.auth_grant_choice = AuthorizationCodeGrantDispatcher(default_grant=self.auth_grant, oidc_grant=self.openid_connect_auth)
6971
self.implicit_grant_choice = ImplicitTokenGrantDispatcher(default_grant=self.implicit_grant, oidc_grant=self.openid_connect_implicit)
7072

7173
# See http://openid.net/specs/oauth-v2-multiple-response-types-1_0.html#Combinations for valid combinations
7274
# internally our AuthorizationEndpoint will ensure they can appear in any order for any valid combination
73-
AuthorizationEndpoint.__init__(self, default_response_type='code',
74-
response_types={
75-
'code': self.auth_grant_choice,
76-
'token': self.implicit_grant_choice,
77-
'id_token': self.openid_connect_implicit,
78-
'id_token token': self.openid_connect_implicit,
79-
'code token': self.openid_connect_hybrid,
80-
'code id_token': self.openid_connect_hybrid,
81-
'code id_token token': self.openid_connect_hybrid,
82-
'none': self.auth_grant
83-
},
84-
default_token_type=self.bearer)
75+
AuthorizationEndpoint.__init__(
76+
self,
77+
default_response_type="code",
78+
response_types={
79+
"code": self.auth_grant_choice,
80+
"token": self.implicit_grant_choice,
81+
"id_token": self.openid_connect_implicit,
82+
"id_token token": self.openid_connect_implicit,
83+
"code token": self.openid_connect_hybrid,
84+
"code id_token": self.openid_connect_hybrid,
85+
"code id_token token": self.openid_connect_hybrid,
86+
"none": self.auth_grant,
87+
},
88+
default_token_type=self.bearer,
89+
)
8590

8691
self.token_grant_choice = AuthorizationTokenGrantDispatcher(request_validator, default_grant=self.auth_grant, oidc_grant=self.openid_connect_auth)
8792

88-
TokenEndpoint.__init__(self, default_grant_type='authorization_code',
89-
grant_types={
90-
'authorization_code': self.token_grant_choice,
91-
'password': self.password_grant,
92-
'client_credentials': self.credentials_grant,
93-
'refresh_token': self.refresh_grant,
94-
},
95-
default_token_type=self.bearer)
96-
ResourceEndpoint.__init__(self, default_token='Bearer',
97-
token_types={'Bearer': self.bearer, 'JWT': self.jwt})
93+
TokenEndpoint.__init__(
94+
self,
95+
default_grant_type="authorization_code",
96+
grant_types={
97+
"authorization_code": self.token_grant_choice,
98+
"password": self.password_grant,
99+
"client_credentials": self.credentials_grant,
100+
"refresh_token": self.refresh_grant,
101+
},
102+
default_token_type=self.bearer,
103+
)
104+
ResourceEndpoint.__init__(self, default_token="Bearer", token_types={"Bearer": self.bearer, "JWT": self.jwt})
98105
RevocationEndpoint.__init__(self, request_validator)
99106
IntrospectEndpoint.__init__(self, request_validator)
100107
UserInfoEndpoint.__init__(self, request_validator)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy