Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit 6ac0cdf

Browse files
committed
Editorial changes.
Removed unused parameters. Changed get_ophash_by_cb_uri to use the provided url.
1 parent e6ee34f commit 6ac0cdf

File tree

5 files changed

+14
-22
lines changed

5 files changed

+14
-22
lines changed

example/flask_rp/views.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logging
2-
import urllib
32
from urllib.parse import parse_qs
3+
from urllib.parse import splitquery
44

55
from flask import Blueprint
66
from flask import current_app
@@ -67,7 +67,8 @@ def rp():
6767
except Exception as err:
6868
return make_response('Something went wrong:{}'.format(err), 400)
6969
else:
70-
return redirect(result['url'], 303)
70+
response = redirect(result['url'], 303)
71+
return response
7172
else:
7273
_providers = current_app.rp_config.clients.keys()
7374
return render_template('opbyuid.html', providers=_providers)
@@ -150,10 +151,10 @@ def finalize(op_hash, request_args):
150151
return make_response(res['error'], 400)
151152

152153

153-
def get_ophash_by_cb_uri(url:str):
154-
uri = urllib.parse.splitquery(request.url)[0]
154+
def get_ophash_by_cb_uri(url: str):
155+
uri = splitquery(url)[0]
155156
clients = current_app.rp_config.clients
156-
for k,v in clients.items():
157+
for k, v in clients.items():
157158
for endpoint in ("redirect_uris",
158159
"post_logout_redirect_uris",
159160
"frontchannel_logout_uri",

src/oidcrp/oauth2/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ def __init__(self, client_authn_factory=None, keyjar=None, verify_ssl=True, conf
7272
# just ignore verify_ssl until it goes away
7373
self.verify_ssl = self.httpc_params.get("verify", True)
7474

75-
def do_request(self, request_type, response_body_type="", request_args=None,
76-
**kwargs):
77-
75+
def do_request(self, request_type, response_body_type="", request_args=None, **kwargs):
7876
_srv = self._service[request_type]
7977

8078
_info = _srv.get_request_parameters(request_args=request_args, **kwargs)
@@ -137,6 +135,7 @@ def service_request(self, service, url, method="GET", body=None,
137135
The method that sends the request and handles the response returned.
138136
This assumes that the response arrives in the HTTP response.
139137
138+
:param service: The Service instance
140139
:param url: The URL to which the request should be sent
141140
:param method: Which HTTP method to use
142141
:param body: A message body if any

src/oidcrp/oauth2/add_on/dpop.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,16 @@ def verify_header(self, dpop_header) -> Optional["DPoPProof"]:
8585

8686

8787
def dpop_header(service_context: ServiceContext,
88-
request: Union[dict, Message],
8988
service_endpoint: str,
9089
http_method: str,
9190
headers: Optional[dict] = None,
92-
authn_method: Optional[str] = "",
9391
**kwargs) -> dict:
9492
"""
9593
9694
:param service_context:
97-
:param request:
9895
:param service_endpoint:
9996
:param http_method:
10097
:param headers:
101-
:param authn_method:
10298
:param kwargs:
10399
:return:
104100
"""
@@ -156,7 +152,8 @@ def add_support(services, signing_algorithms: Optional[list] = None):
156152
"""
157153

158154
_service = services["accesstoken"]
159-
_service.client_get("service_context").add_on['dpop'] = {
155+
_context = _service.client_get("service_context")
156+
_context.add_on['dpop'] = {
160157
# "key": key_by_alg(signing_algorithm),
161158
"sign_algs": signing_algorithms
162159
}

src/oidcrp/rp_handler.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,7 @@ def get_access_token(self, state, client: Optional[Client] = None):
488488
try:
489489
tokenresp = client.do_request(
490490
'accesstoken', request_args=req_args,
491-
authn_method=self.get_client_authn_method(client,
492-
"token_endpoint"),
491+
authn_method=self.get_client_authn_method(client, "token_endpoint"),
493492
state=state
494493
)
495494
except Exception as err:

tests/test_40_dpop.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
import os
22

3-
import pytest
43
from cryptojwt.jws.jws import factory
54
from cryptojwt.key_jar import init_key_jar
5+
import pytest
66

7-
from oidcrp.client_auth import factory as ca_factory
87
from oidcrp.oauth2 import Client
98
from oidcrp.oauth2 import DEFAULT_OAUTH2_SERVICES
10-
from oidcrp.oauth2.add_on import do_add_ons
11-
from oidcrp.service import init_services
12-
from oidcrp.service_context import ServiceContext
139

1410
_dirname = os.path.dirname(os.path.abspath(__file__))
1511

@@ -43,14 +39,14 @@ def create_client(self):
4339

4440
self.client = Client(keyjar=CLI_KEY, config=config, services=DEFAULT_OAUTH2_SERVICES)
4541

46-
self.client.client_get("service_context").provider_info= {
42+
self.client.client_get("service_context").provider_info = {
4743
"authorization_endpoint": "https://example.com/auth",
4844
"token_endpoint": "https://example.com/token",
4945
"dpop_signing_alg_values_supported": ["RS256", "ES256"]
5046
}
5147

5248
def test_add_header(self):
53-
token_serv = self.client.client_get("service","accesstoken")
49+
token_serv = self.client.client_get("service", "accesstoken")
5450
req_args = {
5551
"grant_type": "authorization_code",
5652
"code": "SplxlOBeZQQYbYS6WxSbIA",

0 commit comments

Comments
 (0)