Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Purpose of encoding then decoding request state #130

Open
osamaramihafez opened this issue Aug 17, 2021 · 0 comments
Open

Purpose of encoding then decoding request state #130

osamaramihafez opened this issue Aug 17, 2021 · 0 comments

Comments

@osamaramihafez
Copy link

osamaramihafez commented Aug 17, 2021

I'm still trying to understand the purpose of the custom json loads function and why we are encoding then decoding the request in _process_callback. I'm currently testing the callback endpoint using pytest and I keep getting an "incorrect padding" error whenever we attempt to fetch the state as shown here:

session_csrf_token = session.get('oidc_csrf_token')
state = _json_loads(urlsafe_b64decode(request.args['state'].encode('utf-8')))
csrf_token = state['csrf_token']

Could we not use an alternative for handling requests such as:

# after importing the ast library
csrf_token = ast.literal_eval(request.args.get("state"))["csrf_token"]

This seems to work with requests that come from a flask client while testing with pytest.

data = {"state": {"csrf_token": csrf_token}, "code": "falafel"}
result = client.get("/oidc_callback", query_string = data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant