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

Token information Context params missing #1780

Closed
Subin-Qreative opened this issue Nov 2, 2023 · 3 comments · Fixed by #1792
Closed

Token information Context params missing #1780

Subin-Qreative opened this issue Nov 2, 2023 · 3 comments · Fixed by #1792

Comments

@Subin-Qreative
Copy link

Description

Documentation shows these would be available
{
"api_base_path": ... # The base path of the matched API
"operation_id": ... # The operation id of matched operation
"user": ... # User information from authentication
"token_info": ... # Token information from authentication
}

Expected behaviour

def get_secret(user, token_info, context_) -> str:
print(context_)
return """
You are user_id {user} and the secret is 'wbevuec'.
Decoded token claims: {token_info}.
""".format(
user=user, token_info=token_info
)

print should real all of the context:

{'api_base_path': '/api/auth/{user_id}', 'operation_id': 'app.generate_token', 'user': '12', 'token_info': {'iss': 'com.zalando.connexion', 'iat': 1698962243, 'exp': 1698962843, 'sub': '12'}}

Actual behaviour

{'user': '12', 'token_info': {'iss': 'com.zalando.connexion', 'iat': 1698962243, 'exp': 1698962843, 'sub': '12'}}

Steps to reproduce

Followed instructions as per :
https://connexion.readthedocs.io/en/stable/request.html#context

using

https://github.com/spec-first/connexion/tree/main/examples/jwt

Additional info:

Output of the commands:

  • python --version Python 3.10.12
  • pip show connexion | grep "^Version\:" Version: 3.0.0
@RobbeSneyders
Copy link
Member

Thanks @Subin-Qreative. Seems like this is a mistake in the documentation. The api_base_path and operation_id are stored under a separate key which is not included in the context that is made available.

Is there a reason you want to access these parameters?

@Subin-Qreative
Copy link
Author

no particular reason, i was trying to wrap my head around / understand how the "user" parameter was exposed and came to find the following.

@RobbeSneyders
Copy link
Member

RobbeSneyders commented Nov 2, 2023

Ok, then I will update the documentation to match the current behavior. Thanks for reporting!

Let me know if something is still unclear so we can document it better.

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

Successfully merging a pull request may close this issue.

2 participants