Skip to content

Commit 0290fb0

Browse files
authored
Merge pull request #104 from IdentityPython/response_type_handling
Response type handling
2 parents 56a4799 + 0dc1dc0 commit 0290fb0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+362
-235
lines changed

.coveragerc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
# .coveragerc to control coverage.py
22
[run]
3+
branch = true
4+
omit = */tests/*, */wsgi.py, fabfile.py, /usr/local/*, ./setup.py
35
source = .
6+
7+
[report]
8+
show_missing = true

.github/workflows/python-app.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ jobs:
1818
fail-fast: false
1919
matrix:
2020
python-version:
21-
- '3.7'
2221
- '3.8'
2322
- '3.9'
2423
- '3.10'
24+
- '3.11'
2525

2626
steps:
2727
- uses: actions/checkout@v2

doc/client/add_on/dpop.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ in a client configuration.
4040
4141
'add_ons': {
4242
"dpop": {
43-
"function": "oidcrp.oauth2.add_on.dpop.add_support",
43+
"function": "idpyoidc.client.oauth2.add_on.dpop.add_support",
4444
"kwargs": {
4545
"signing_algorithms": ["ES256", "ES512"]
4646
}

doc/client/add_on/pushed_authorization.rst

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,39 @@ Pushed Authorization
88
Introduction
99
------------
1010

11-
https://tools.ietf.org/id/draft-lodderstedt-oauth-par-00.html
11+
https://datatracker.ietf.org/doc/html/rfc9126
1212

13-
The Internet draft defines the pushed authorization request endpoint,
13+
The Internet draft defines the pushed authorization request (PAR) endpoint,
1414
which allows clients to push the payload of an OAuth 2.0 authorization
1515
request to the authorization server via a direct request and provides
1616
them with a request URI that is used as reference to the data in a
17-
subsequent authorization request.
17+
subsequent authorization request.
18+
19+
-------------
20+
Configuration
21+
-------------
22+
23+
There is basically one things you can configure:
24+
25+
- authn_method
26+
Which client authentication method that should be used at the pushed authorization endpoint.
27+
Default is none.
28+
29+
-------
30+
Example
31+
-------
32+
33+
What you have to do is to add a *par* section to an *add_ons* section
34+
in a client configuration.
35+
36+
.. code:: python
37+
38+
'add_ons': {
39+
"par": {
40+
"function": "idpyoidc.client.oauth2.add_on.par.add_support",
41+
"kwargs": {
42+
"authn_method": "private_key_jwt"
43+
}
44+
}
45+
}
46+

example/flask_op/config.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
}
9292
}
9393
},
94-
"capabilities": {
94+
"preference": {
9595
"subject_types_supported": [
9696
"public",
9797
"pairwise"
@@ -260,6 +260,7 @@
260260
"verify": false
261261
},
262262
"issuer": "https://{domain}:{port}",
263+
"entity_id": "https://{domain}:{port}",
263264
"keys": {
264265
"private_path": "private/jwks.json",
265266
"key_defs": [
@@ -277,9 +278,8 @@
277278
]
278279
}
279280
],
280-
"public_path": "static/jwks.json",
281281
"read_only": false,
282-
"uri_path": "static/jwks.json"
282+
"uri_path": "jwks"
283283
},
284284
"login_hint2acrs": {
285285
"class": "idpyoidc.server.login_hint.LoginHint2Acrs",
@@ -349,6 +349,6 @@
349349
"verify_user": false,
350350
"port": 5000,
351351
"domain": "127.0.0.1",
352-
"debug": true
352+
"debug": false
353353
}
354354
}

example/flask_op/views.py

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
import json
2-
import os
32
import sys
43
import traceback
54
from typing import Union
65
from urllib.parse import urlparse
76

7+
import werkzeug
88
from cryptojwt import as_unicode
99
from flask import Blueprint
10-
from flask import Response
1110
from flask import current_app
1211
from flask import redirect
1312
from flask import render_template
1413
from flask import request
14+
from flask import Response
1515
from flask.helpers import make_response
16-
from flask.helpers import send_from_directory
16+
1717
from idpyoidc.message.oauth2 import ResponseMessage
1818
from idpyoidc.message.oidc import AccessTokenRequest
1919
from idpyoidc.message.oidc import AuthorizationRequest
20-
import werkzeug
21-
22-
from idpyoidc.server.exception import FailedAuthentication
2320
from idpyoidc.server.exception import ClientAuthenticationError
21+
from idpyoidc.server.exception import FailedAuthentication
2422
from idpyoidc.server.oidc.token import Token
2523

2624
# logger = logging.getLogger(__name__)
@@ -29,8 +27,8 @@
2927

3028

3129
def _add_cookie(resp: Response, cookie_spec: Union[dict, list]):
32-
kwargs = {k:v
33-
for k,v in cookie_spec.items()
30+
kwargs = {k: v
31+
for k, v in cookie_spec.items()
3432
if k not in ('name',)}
3533
kwargs["path"] = "/"
3634
kwargs["samesite"] = "Lax"
@@ -44,15 +42,22 @@ def add_cookie(resp: Response, cookie_spec: Union[dict, list]):
4442
elif isinstance(cookie_spec, dict):
4543
_add_cookie(resp, cookie_spec)
4644

47-
@oidc_op_views.route('/static/<path:path>')
48-
def send_js(path):
49-
return send_from_directory('static', path)
5045

46+
# @oidc_op_views.route('/static/<path:path>')
47+
# def send_js(path):
48+
# return send_from_directory('static', path)
49+
#
50+
#
51+
# @oidc_op_views.route('/keys/<jwks>')
52+
# def keys(jwks):
53+
# fname = os.path.join('static', jwks)
54+
# return open(fname).read()
55+
#
5156

52-
@oidc_op_views.route('/keys/<jwks>')
53-
def keys(jwks):
54-
fname = os.path.join('static', jwks)
55-
return open(fname).read()
57+
@oidc_op_views.route('/jwks')
58+
def jwks():
59+
_context = current_app.server.get_context()
60+
return _context.keyjar.export_jwks()
5661

5762

5863
@oidc_op_views.route('/')
@@ -188,11 +193,13 @@ def token():
188193
return service_endpoint(
189194
current_app.server.get_endpoint('token'))
190195

196+
191197
@oidc_op_views.route('/introspection', methods=['POST'])
192198
def introspection_endpoint():
193199
return service_endpoint(
194200
current_app.server.get_endpoint('introspection'))
195201

202+
196203
@oidc_op_views.route('/userinfo', methods=['GET', 'POST'])
197204
def userinfo():
198205
return service_endpoint(

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ classifiers =[
2424
[options]
2525
package_dir = "src"
2626
packages = "find:"
27-
python= "^3.6"
27+
python= "^3.8"
2828

2929
[tool.black]
3030
line-length = 100

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,13 @@ def run_tests(self):
6363
classifiers=[
6464
"Development Status :: 4 - Beta",
6565
"License :: OSI Approved :: Apache Software License",
66-
"Programming Language :: Python :: 3.7",
6766
"Programming Language :: Python :: 3.8",
6867
"Programming Language :: Python :: 3.9",
6968
"Programming Language :: Python :: 3.10",
7069
"Programming Language :: Python :: 3.11",
7170
"Topic :: Software Development :: Libraries :: Python Modules"],
7271
install_requires=[
73-
"cryptojwt>=1.8.3",
72+
"cryptojwt>=1.8.4",
7473
"pyOpenSSL",
7574
"filelock>=3.0.12",
7675
'pyyaml>=5.1.2',

src/idpyoidc/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__author__ = "Roland Hedberg"
2-
__version__ = "4.2.0"
2+
__version__ = "4.3.0"
33

44
VERIFIED_CLAIM_PREFIX = "__verified"
55

src/idpyoidc/client/oauth2/add_on/dpop.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ def dpop_header(
9999
headers: Optional[dict] = None,
100100
token: Optional[str] = "",
101101
nonce: Optional[str] = "",
102+
endpoint_url: Optional[str] = "",
102103
**kwargs
103104
) -> dict:
104105
"""
@@ -114,7 +115,11 @@ def dpop_header(
114115
:return:
115116
"""
116117

117-
provider_info = service_context.provider_info
118+
if not endpoint_url:
119+
endpoint_url = kwargs.get("endpoint")
120+
if not endpoint_url:
121+
endpoint_url = service_context.provider_info[service_endpoint]
122+
118123
_dpop_conf = service_context.add_on.get("dpop")
119124
if not _dpop_conf:
120125
logger.warning("Asked to do dpop when I do not support it")
@@ -139,7 +144,7 @@ def dpop_header(
139144
"jwk": dpop_key.serialize(),
140145
"jti": uuid.uuid4().hex,
141146
"htm": http_method,
142-
"htu": provider_info[service_endpoint],
147+
"htu": endpoint_url,
143148
"iat": utc_time_sans_frac(),
144149
}
145150

0 commit comments

Comments
 (0)