Skip to content

Avoid tokens of trusted web clients after a password reset - #398

Merged
OmarIthawi merged 1 commit into
appsembler/tahoe/developfrom
omar/avoid-removing-amc-tokens
Jul 2, 2019
Merged

Avoid tokens of trusted web clients after a password reset#398
OmarIthawi merged 1 commit into
appsembler/tahoe/developfrom
omar/avoid-removing-amc-tokens

Conversation

@OmarIthawi

@OmarIthawi OmarIthawi commented Jun 15, 2019

Copy link
Copy Markdown

Description

Filip found out that the missing AMC tokens is an Open edX feature after a password reset.

This fixes the issue by avoid removing the tokens for TrustedClient like the AMC.

See: https://tahoe.appsembler.com/admin/edx_oauth2_provider/trustedclient/

And yes, it has tests 😉

Questions

  • Should I put this behind a feature or Wafl flag? Just in case we found out it's dangerous? @melvinsoft says yes! Done.
  • How do we prevent marking mobile clients as trusted? Fixed
  • Do you think the tests are solid? Or should test more intensively? Done

@OmarIthawi
OmarIthawi force-pushed the omar/avoid-removing-amc-tokens branch from 90be410 to 01d3b7d Compare June 15, 2019 09:33
@OmarIthawi

Copy link
Copy Markdown
Author

thraxil
thraxil previously approved these changes Jun 17, 2019

@thraxil thraxil left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be useful to push upstream? Or is the token removal something that only affects us?

@OmarIthawi

Copy link
Copy Markdown
Author

Thanks @thraxil! I think it would be useful, I'll check with the Open edX folks.

melvinsoft
melvinsoft previously approved these changes Jun 18, 2019

@melvinsoft melvinsoft left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OmarIthawi Thanks for fixing this, it looks good to me!

I second @thraxil comment, we should push it upstream.

Also, regarding your questions, I think put behind a feature flag would be great, we're trying to get our enterprise and tahoe branches together, and this could be an undesired behaviour for enterprise customers.

@OmarIthawi

Copy link
Copy Markdown
Author

Thanks @melvinsoft! I've already pushed it upstream, but it's going to be a long time before we can get a response from the Open edX folks.

So I'll put it behind a feature flag, disabled by default.

@OmarIthawi OmarIthawi changed the title Avoid removing AMC tokens after a password reset (WIP) Avoid removing AMC tokens after a password reset Jun 18, 2019
@OmarIthawi

Copy link
Copy Markdown
Author

@melvinsoft what about the other questions. I'd love to get what you think on them!

@iamjazzar iamjazzar left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the tests, @OmarIthawi! Some is always better than nothing.

I think this change will create a confusion in edx-oauth2-provider library as its documentation clearly stated the purpose behind the TrustedClient:

   """ 
   By default `django-oauth2-provider` shows a consent form to the
   user after his credentials has been validated. Trusted clients
   bypass the user consent and redirect to the OAuth2 client
   directly.
   """ 

One change here we can make is to add a flag to by passing the consent and/or another one to allow destroying OAuth tokens. What do you think?

Regarding your questions:

Should I put this behind a feature or Wafl flag? Just in case we found out it's dangerous? @melvinsoft says yes!?

I recommend this! It'll reduce the maintenance effort in the future, which is going to accelerate the development time by then 😉

How do we prevent marking mobile clients as trusted?

See my suggestion above ↑

Do you think the tests are solid? Or should test more intensively?

Those are good for now, more might be needed later. I still don't know if we can run all edx-platform tests in this repo?

@OmarIthawi

This comment has been minimized.

@OmarIthawi

Copy link
Copy Markdown
Author

Thanks @AhmedAljazzar!

Thanks for the tests, @OmarIthawi! Some is always better than nothing.

😄

I think this change will create a confusion in edx-oauth2-provider library as its documentation clearly stated the purpose behind the TrustedClient:

   """ 
   By default `django-oauth2-provider` shows a consent form to the
   user after his credentials has been validated. Trusted clients
   bypass the user consent and redirect to the OAuth2 client
   directly.
   """ 

Great catch! Thanks a lot for checking this.

One change here we can make is to add a flag to by passing the consent and/or another one to allow destroying OAuth tokens. What do you think?

I don't think it makes sense to disable the original behavior. So adding one more feature flag to toggle the new behavior sounds like a good option to me.

Regarding your questions:

Should I put this behind a feature or Wafl flag? Just in case we found out it's dangerous? @melvinsoft says yes!?

I recommend this! It'll reduce the maintenance effort in the future, which is going to accelerate the development time by then

How do we prevent marking mobile clients as trusted?

See my suggestion above ↑

Not sure I understand what you mean. Anyway, I think it's a minor point that we can address later.

Do you think the tests are solid? Or should test more intensively?

Those are good for now, more might be needed later. I still don't know if we can run all edx-platform tests in this repo?

No we don't have that. We used to have it for Ficus but we didn't get to it in Hawthorn yet.

@OmarIthawi
OmarIthawi requested a review from iamjazzar June 19, 2019 10:53
@iamjazzar

Copy link
Copy Markdown

Not sure I understand what you mean. Anyway, I think it's a minor point that we can address later.

@OmarIthawi What I meant is: if we decided to go with implementing a flag for the new behavior, then we will be able to disable this flag for mobile clients (Or any other client technically). I don't know if edX creates mobile clients upon deployment, but if so, we can store those mobile clients with this flag set as disabled to skip the behavior.

I wonder what edX will say about this though.

@OmarIthawi

Copy link
Copy Markdown
Author

@OmarIthawi What I meant is: if we decided to go with implementing a flag for the new behavior, then we will be able to disable this flag for mobile clients (Or any other client technically). I don't know if edX creates mobile clients upon deployment, but if so, we can store those mobile clients with this flag set as disabled to skip the behavior.

Ah, got you! I think this is something that I didn't think about! Mobile clients are indeed marked trusted sometimes. I have no idea how to separate mobile client from others.

What do you suggest?

I wonder what edX will say about this though.

That'll take sometime. But I think it's worth the wait.

@melvinsoft

Copy link
Copy Markdown

@OmarIthawi I agreed with @AhmedAljazzar here, those test look enough for now.

Regarding the mobile clients, I don't fully understand the question, I think mobile clients are always trusted.

@OmarIthawi
OmarIthawi force-pushed the omar/avoid-removing-amc-tokens branch from 01d3b7d to 31940d4 Compare June 24, 2019 07:30
@OmarIthawi OmarIthawi changed the title (WIP) Avoid removing AMC tokens after a password reset Avoid removing AMC tokens after a password reset Jun 24, 2019
@OmarIthawi OmarIthawi changed the title Avoid removing AMC tokens after a password reset Avoid tokens of trusted web clients after a password reset Jun 24, 2019
@OmarIthawi
OmarIthawi force-pushed the omar/avoid-removing-amc-tokens branch from 31940d4 to 773949d Compare June 24, 2019 07:48
@OmarIthawi
OmarIthawi requested review from melvinsoft and thraxil June 24, 2019 07:49
@OmarIthawi
OmarIthawi dismissed stale reviews from melvinsoft and thraxil June 24, 2019 07:50

Outdated.

@OmarIthawi

Copy link
Copy Markdown
Author

@AhmedAljazzar @melvinsoft @thraxil I've added a feature flag and now the function removes the tokens for mobile applications even if they're trusted.

Now all the known issues of the original code are resolved. Please take another look and let me know what do you think.

Comment thread common/djangoapps/student/tests/test_helpers.py Outdated
Comment thread common/djangoapps/student/tests/test_helpers.py Outdated
Comment thread common/djangoapps/student/tests/test_helpers.py Outdated
Comment thread common/djangoapps/student/tests/test_helpers.py Outdated
@OmarIthawi
OmarIthawi force-pushed the omar/avoid-removing-amc-tokens branch from 773949d to 541a410 Compare June 25, 2019 15:55
@OmarIthawi

OmarIthawi commented Jun 25, 2019

Copy link
Copy Markdown
Author

Thanks @thraxil for the review!

@AhmedAljazzar one more look please!

@OmarIthawi
OmarIthawi force-pushed the omar/avoid-removing-amc-tokens branch from 301f7b3 to ce20e16 Compare June 25, 2019 16:38

@melvinsoft melvinsoft left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OmarIthawi Thanks for implementing the changes! Let's try it on Staging!

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 this pull request may close these issues.

4 participants