Skip to content
This repository was archived by the owner on Jun 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
bbc7929
Client registration endpoint should return a 201 HTTP response code o…
rohe Aug 31, 2021
178ca74
Default token lifetime should not be 0 (zero). Changed to be 30 minut…
rohe Sep 1, 2021
ce142a8
Userinfo endpoint should support POST.
rohe Sep 2, 2021
6f87892
Authorization error response MUST contain 'state' if it is present in…
rohe Sep 2, 2021
32640c1
Authorization error response MUST contain 'state' if it is present in…
rohe Sep 2, 2021
a158741
Cookie handling - bug, wrong name.
rohe Sep 2, 2021
e7303bc
Cookie handling - bug, wrong name.
rohe Sep 2, 2021
f2b8ea2
Cookie handling - bug, wrong name.
rohe Sep 2, 2021
0003078
Cookie handling - bug, wrong name.
rohe Sep 2, 2021
fcfd63b
Cookie handling - bug, wrong name.
rohe Sep 2, 2021
6659459
Cookie handling - bug, wrong name.
rohe Sep 2, 2021
71c77b6
Cookie handling - bug, wrong name.
rohe Sep 2, 2021
5cfa289
parse_cookie twice.
rohe Sep 2, 2021
f384d20
parse_cookie twice.
rohe Sep 2, 2021
5146010
parse_cookie twice.
rohe Sep 2, 2021
c57bd80
parse_cookie twice.
rohe Sep 2, 2021
031cd28
parse_cookie twice.
rohe Sep 2, 2021
93e9589
More logging
rohe Sep 3, 2021
cc6337a
More logging
rohe Sep 3, 2021
bf595db
Too old authentication
rohe Sep 3, 2021
c0607d5
Too old authentication - logging
rohe Sep 3, 2021
bef128e
Too old authentication
rohe Sep 3, 2021
f7cc53a
Cookie info
rohe Sep 3, 2021
0ea0cea
Cookie info
rohe Sep 3, 2021
ff35728
Wrong error code.
rohe Sep 3, 2021
93eb7a7
Revoke tokens that has been minted using a code that then is used onc…
rohe Sep 3, 2021
fc59033
Undefined max age
rohe Sep 3, 2021
007fc0e
Correct user.
rohe Sep 3, 2021
9188cac
logging
rohe Sep 3, 2021
88da05a
logging
rohe Sep 3, 2021
5879a9a
Verify correct user
rohe Sep 3, 2021
f061a88
Verify correct user
rohe Sep 3, 2021
2c8b44c
prompt==login forces reauthentication.
rohe Sep 6, 2021
de49d67
prompt==login forces reauthentication.
rohe Sep 6, 2021
f0d2d8c
prompt==login forces reauthentication.
rohe Sep 6, 2021
4ee4b3f
prompt==login forces reauthentication.
rohe Sep 6, 2021
22e3b7d
prompt==login forces reauthentication.
rohe Sep 6, 2021
a61e27e
Prompt is a list.
rohe Sep 6, 2021
984eb5a
Prompt is a list.
rohe Sep 6, 2021
768dc30
Merge branch 'develop' into certification
rohe Sep 7, 2021
3abbb14
Fixed cookie_info().
rohe Sep 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions example/flask_op/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,16 @@ def do_response(endpoint, req_args, error='', **args):
if error:
if _response_placement == 'body':
_log.info('Error Response: {}'.format(info['response']))
resp = make_response(info['response'], 400)
_http_response_code = info.get('response_code', 400)
resp = make_response(info['response'], _http_response_code)
else: # _response_placement == 'url':
_log.info('Redirect to: {}'.format(info['response']))
resp = redirect(info['response'])
else:
if _response_placement == 'body':
_log.info('Response: {}'.format(info['response']))
resp = make_response(info['response'], 200)
_http_response_code = info.get('response_code', 200)
resp = make_response(info['response'], _http_response_code)
else: # _response_placement == 'url':
_log.info('Redirect to: {}'.format(info['response']))
resp = redirect(info['response'])
Expand Down Expand Up @@ -166,10 +168,14 @@ def registration():
current_app.server.server_get("endpoint", 'registration'))


@oidc_op_views.route('/registration_api', methods=['GET'])
@oidc_op_views.route('/registration_api', methods=['GET', 'DELETE'])
def registration_api():
return service_endpoint(
current_app.server.server_get("endpoint", 'registration_read'))
if request.method == "DELETE":
return service_endpoint(
current_app.server.server_get("endpoint", 'registration_delete'))
else:
return service_endpoint(
current_app.server.server_get("endpoint", 'registration_read'))


@oidc_op_views.route('/authorization')
Expand Down Expand Up @@ -245,10 +251,14 @@ def service_endpoint(endpoint):
err_msg = ResponseMessage(error='invalid_request', error_description=str(err))
return make_response(err_msg.to_json(), 400)

_log.info('request: {}'.format(req_args))
if isinstance(req_args, ResponseMessage) and 'error' in req_args:
return make_response(req_args.to_json(), 400)
_log.info('Error response: {}'.format(req_args))
_resp = make_response(req_args.to_json(), 400)
if request.method == "POST":
_resp.headers["Content-type"] = "application/json"
return _resp
try:
_log.info('request: {}'.format(req_args))
if isinstance(endpoint, Token):
args = endpoint.process_request(AccessTokenRequest(**req_args), http_info=http_info)
else:
Expand Down
10 changes: 8 additions & 2 deletions src/oidcop/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@
"max_usage": 1,
},
"access_token": {},
"refresh_token": {"supports_minting": ["access_token", "refresh_token"]},
"refresh_token": {
"supports_minting": ["access_token", "refresh_token"],
"expires_in": -1
},
},
"expires_in": 43200,
}
Expand Down Expand Up @@ -380,7 +383,10 @@ def __init__(
"max_usage": 1,
},
"access_token": {},
"refresh_token": {"supports_minting": ["access_token", "refresh_token"]},
"refresh_token": {
"supports_minting": ["access_token", "refresh_token"],
"expires_in": -1
},
},
"expires_in": 43200,
}
Expand Down
2 changes: 2 additions & 0 deletions src/oidcop/constant.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
DIVIDER = ";;"

DEFAULT_TOKEN_LIFETIME = 1800
17 changes: 13 additions & 4 deletions src/oidcop/cookie_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ def _ver_dec_content(self, parts):
try:
msg = decrypter.decrypt(ciphertext, iv, tag=tag)
except InvalidTag:
LOGGER.debug("Decryption failed")
return None

p = lv_unpack(msg.decode("utf-8"))
Expand All @@ -180,6 +181,8 @@ def _ver_dec_content(self, parts):
self.sign_key.key,
):
return payload, timestamp
else:
LOGGER.debug("Could not verify signature")
else:
return payload, timestamp
return None
Expand Down Expand Up @@ -247,12 +250,18 @@ def parse_cookie(self, name: str, cookies: List[dict]) -> Optional[List[dict]]:
if not cookies:
return None

LOGGER.debug("Looking for '{}' cookies".format(name))
res = []
for _cookie in cookies:
if _cookie["name"] == name:
payload, timestamp = self._ver_dec_content(_cookie["value"].split("|"))
value, typ = payload.split("::")
res.append({"value": value, "type": typ, "timestamp": timestamp})
LOGGER.debug('Cookie: {}'.format(_cookie))
if "name" in _cookie and _cookie["name"] == name:
_content = self._ver_dec_content(_cookie["value"].split("|"))
if _content:
payload, timestamp = self._ver_dec_content(_cookie["value"].split("|"))
value, typ = payload.split("::")
res.append({"value": value, "type": typ, "timestamp": timestamp})
else:
LOGGER.debug(f"Could not verify {name} cookie")
return res


Expand Down
16 changes: 8 additions & 8 deletions src/oidcop/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,6 @@ def __init__(self, server_get: Callable, **kwargs):
self.allowed_targets = [self.name]
self.client_verification_method = []

def parse_cookies(self, cookies: List[dict], context: EndpointContext, name: str):
res = context.cookie_handler.parse_cookie(name, cookies)
return res

def parse_request(
self, request: Union[Message, dict, str], http_info: Optional[dict] = None, **kwargs
):
Expand Down Expand Up @@ -330,10 +326,9 @@ def do_response(
resp = None
if error:
_response = ResponseMessage(error=error)
try:
_response["error_description"] = kwargs["error_description"]
except KeyError:
pass
for attr in ["error_description", "error_uri", "state"]:
if attr in kwargs:
_response[attr] = kwargs[attr]
elif "response_msg" in kwargs:
resp = kwargs["response_msg"]
_response_placement = kwargs.get("response_placement")
Expand Down Expand Up @@ -405,6 +400,11 @@ def do_response(
except KeyError:
pass

try:
_resp["response_code"] = kwargs["response_code"]
except KeyError:
pass

return _resp

def allowed_target_uris(self):
Expand Down
Loading