Repository navigation
Ryan morosa/bb2 5225 tie jwt verification into token endpoint asymmetric auth - #1774
ryan-morosa wants to merge 20 commits into
Conversation
…into-token-endepoint-asymmetric-auth
…into-token-endepoint-asymmetric-auth
…into-token-endepoint-asymmetric-auth
…into-token-endepoint-asymmetric-auth
|
Is it okay to include logging in a different story? I think it coould be good to add to the scope of that here: https://jira.cms.gov/browse/BB2-5295 For this question, I guess it depends on when we think 5295 will be completed, and whether or not this functionality will be used before the logging is in place. If the functionality won't be used before the logging is added, I think it's fine to do it in 5295. If the functionality will be used before 5295 is merged, i'd say we should include it here. I'm not sure exactly where asymmetric auth is at right now |
yeah I think we talked about it at eng sync and it looks like we just included it as a part of 5295. |
|
Validation steps all worked for me! Will go through the rest of the code review first thing tomorrow. |
| ) | ||
| from apps.dot_ext.constants import ( | ||
| APPLICATION_DOES_NOT_HAVE_CLIENT_CREDENTIALS_ENABLED, | ||
| APPLICATION_DOES_NOT_HAVE_THIS_AUTH_TYPE_ENABLED, |
There was a problem hiding this comment.
Making this comment to ensure we create the asymmetric_auth_validation waffle switch in test, sbx, and prod after this gets deployed. Probably needs to be noted in the next upcoming deployment management ticket.
There was a problem hiding this comment.
That switch was already introduced right? Even if not, we can pre-emptively add the switch, might be worth doing that as part of your ticket to avoid missing it in deployment.
JamesDemeryNava
left a comment
There was a problem hiding this comment.
Validation steps work and tests look good! Left a few comments, and should probably wait for Jimmy to approve as well.
jimmyfagan
left a comment
There was a problem hiding this comment.
Didn't have a chance to test this out yet, but left some comments based on looking at the changes, I have a feeling some refactor here might be useful, the token post method is kind of messy given all of the different paths that go through that method, and I like the instinct to extract some of the request validation logic, I just don't know if the validators is the best place for that.
Also to answer your question from the description, scope should be required here, in particular because we require it for authorization_code token requests in v3, and asymmetric auth should only be on v3.
…into-token-endepoint-asymmetric-auth
…into-token-endepoint-asymmetric-auth
…into-token-endepoint-asymmetric-auth
…ertion type is already passed
…asymmetric auth apps
…into-token-endepoint-asymmetric-auth
jimmyfagan
left a comment
There was a problem hiding this comment.
I like the improvements, will keep an eye out for more re-reviews
| ) | ||
| from apps.dot_ext.constants import ( | ||
| APPLICATION_DOES_NOT_HAVE_CLIENT_CREDENTIALS_ENABLED, | ||
| APPLICATION_DOES_NOT_HAVE_THIS_AUTH_TYPE_ENABLED, |
There was a problem hiding this comment.
That switch was already introduced right? Even if not, we can pre-emptively add the switch, might be worth doing that as part of your ticket to avoid missing it in deployment.
| @override_switch('asymmetric_auth_validation', active=True) | ||
| @override_switch('v3_endpoints', active=True) | ||
| def test_asymmetric_auth_flow_integration_successful(basic_user, create_application, create_capability): | ||
| def test_asymmetric_auth_flow_integration( |
There was a problem hiding this comment.
Having some readability issues figuring out what these cases are. Can the parameters be named in the cases listed above to make it more clear which boolean goes to what? If not, maybe in-line comment labels or something? Probably some opportunity for us to adopt a new style guideline here. Can we add a function comment that describes what each parameter represents? In particular, token_request_fields, remove_field, add_field, field, are not very intuitive to me. These seem to work, but making them more human readable I think helps maintain, troubleshoot, and add new tests when needed.
There was a problem hiding this comment.
totally fair - I'll try to see if there's a better way/add some doc strings
| # client_assertion and client_assertion_type and they are only | ||
| # approved for asymmetric auth | ||
| # (An Asymmetric-Only app has a jwks_uri but its client_secret_plain field is completely empty) | ||
| is_asymmetric_only = bool(app.jwks_uri and not app.client_secret_plain) |
There was a problem hiding this comment.
Do you know if we ever hit this case? I think it remains to be seen how an asymmetric-only app would be set, but as it is right now, it would still have a client secret since the client secret is set when the app is created. I suspect we may eventually want to add something like this if that changes, but as it is now, I don't know that this is necessary.
There was a problem hiding this comment.
Gotcha. Yeah I though it would be good to add this piece after working on https://jira.cms.gov/browse/BB2-5229 since it looked like we might lean toward no client secret for asymmetric auth being set but I can remove it and make it a separate story if we think that's better. Might've scope creeped this story a bit.
JIRA Ticket:
BB2-5225
What Does This PR Do?
This PR ties the rest of asymmetric auth worked on from BB2-5227 into the token endpoint. We can now get an access_token_response with all the fields in it going through an asymmetric auth flow.
Summary Of Changes:
What Should Reviewers Watch For?
If you're reviewing this PR, please check for these things in particular:
Validation
make run-local CAN_INTEGRATION_TEST=trueand add a print statement of the access_token_response at the end of the asymmetric auth flow test and then runpytest -s apps/fhir/bluebutton/tests/test_jwt_integration.py::test_asymmetric_auth_flow_integration_successfulto see the actual token response with everything in it.What Security Implications Does This PR Have?
Please indicate if this PR does any of the following:
security engineer's approval.
Any Migrations?
etc)