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

Commit 374c04b

Browse files
committed
Added an endpoint that supports RFC7662. - Cleaning.
1 parent 53bb77d commit 374c04b

4 files changed

Lines changed: 13 additions & 23 deletions

File tree

src/oidcendpoint/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
JOSE_ENCODED = "application/jose"
2424

2525

26-
def sanitize(str):
27-
return str
26+
def sanitize(txt):
27+
return txt
2828

2929

3030
def rndstr(size=16):

src/oidcendpoint/endpoint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def client_authentication(self, request, auth=None, **kwargs):
151151
:py:class:`oidcendpoint.endpoint_context.SrvInfo` instance
152152
:param request: Parsed request, a self.request_cls class instance
153153
:param authn: Authorization info
154-
:return: client_id or raise and exception
154+
:return: client_id or raise an exception
155155
"""
156156

157157
return verify_client(self.endpoint_context, request, auth)

src/oidcendpoint/oauth2/introspection.py

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,13 @@
1212

1313

1414
class Introspection(Endpoint):
15+
"""Implements RFC 7662"""
1516
request_cls = oauth2.TokenIntrospectionRequest
1617
response_cls = oauth2.TokenIntrospectionResponse
1718
request_format = 'urlencoded'
1819
response_format = 'json'
1920
endpoint_name = 'introspection'
2021

21-
def do_response(self, response_args=None, request=None, **kwargs):
22-
"""Construct an Introspection response.
23-
24-
:param response_args:
25-
:param request:
26-
:param kwargs: request arguments
27-
:return: Response information
28-
"""
29-
info = {
30-
'response': response_args.to_json(),
31-
'http_headers': [('Content-type', 'application/json')]
32-
}
33-
34-
return info
35-
3622
def client_authentication(self, request, auth=None, **kwargs):
3723
"""
3824
Deal with client authentication
@@ -58,14 +44,14 @@ def client_authentication(self, request, auth=None, **kwargs):
5844

5945
return auth_info
6046

61-
def process_request(self, request_info=None, **kwargs):
47+
def process_request(self, request=None, **kwargs):
6248
"""
6349
64-
:param request_info: The authorization request as a dictionary
50+
:param request: The authorization request as a dictionary
6551
:param kwargs:
6652
:return:
6753
"""
68-
_introspect_request = self.request_cls(**request_info)
54+
_introspect_request = self.request_cls(**request)
6955

7056
_jwt = JWT(key_jar=self.endpoint_context.keyjar)
7157

@@ -83,7 +69,8 @@ def process_request(self, request_info=None, **kwargs):
8369
if 'release' in self.kwargs:
8470
if 'username' in self.kwargs['release']:
8571
try:
86-
_jwt_info['username'] = self.endpoint_context.userinfo.search(sub=_jwt_info['sub'])
72+
_jwt_info['username'] = self.endpoint_context.userinfo.search(
73+
sub=_jwt_info['sub'])
8774
except KeyError:
8875
return {'response': {'active': False}}
8976

tests/test_31_introspection.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,10 @@ def test_do_response(self):
149149
msg_info = self.introspection_endpoint.do_response(request=_req, **_resp)
150150
assert isinstance(msg_info, dict)
151151
assert set(msg_info.keys()) == {'response', 'http_headers'}
152-
assert msg_info['http_headers'] == [('Content-type', 'application/json')]
152+
assert msg_info['http_headers'] == [
153+
('Content-type', 'application/json'),
154+
('Pragma', 'no-cache'),
155+
('Cache-Control', 'no-store')]
153156
_payload = json.loads(msg_info['response'])
154157
assert set(_payload.keys()) == {'sub', 'username', 'exp', 'iat', 'aud',
155158
'active', 'iss', 'jti'}

0 commit comments

Comments
 (0)