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

Currently a way to pull Cognito Auth claims from the request? #558

Closed
kevinpaulconnor opened this issue Sep 28, 2017 · 2 comments
Closed

Comments

@kevinpaulconnor
Copy link

I'm interested in logging information about which Cognito authorized users are making chalice requests. Briefly in late 2016/early 2017, it looks like the Cognito claims were included as a top level item on the Request object: b5030ca#diff-92c4bff78ea0a0fdf94c7dae50063163

This object was removed here:
#240

with the comment, "Need to figure out claims key. This was originally a top level key,
and I believe this is now moved into the request context. Need to double check."

As far as I can tell, the claims aren't currently being passed along with my request context. I am getting the token in my authorization header, and in the short term I can decode that for the user information, but I'm not thrilled with that as a long term solution.

Is there currently a straightforward way to access Cognito claims that I am missing? Or does that need attention.

Thanks!

@kyleknap
Copy link
Contributor

kyleknap commented Oct 2, 2017

Yeah the claims should be available through the request.context property. I have an example of how you can do this in a sample chalice trivia application that I wrote where it uses a CognitoUserPoolAuthorizer for authorization: https://github.com/kyleknap/chalice-trivia/blob/3c23543c511db10e1b2a60e306daec2c1079d998/app.py#L82-L84

Let us know if using the request.context property works for you.

@kevinpaulconnor
Copy link
Author

Thank you, that is very helpful-and I'm sure that other parts of this sample app will be a useful reference as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants