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

refactor!: GoogleOAuth #16935

Merged
merged 37 commits into from
Jul 13, 2022
Merged

refactor!: GoogleOAuth #16935

merged 37 commits into from
Jul 13, 2022

Conversation

phot0n
Copy link
Contributor

@phot0n phot0n commented May 19, 2022

Changes:

  • moved (common) google oauth stuff to a single class
  • made a singular google callback as opposed to multiple whitelisting [breaking change] - except for google calendar
  • added a generic oauth interface for emails (only enabled it for gmail - visible if the user selects service as GMail)
  • added unique constraint on email_id field in email account doctype
  • made X-Original-From header in email body consistent and non-changable even if the user chooses to change sender name/address
  • added new field Used Oauth in User Email doctype to track awaiting password emails (except the ones who've used oauth)
  • fixed field label inconsistencies in email account doctype
  • fetched attachment_limit in email account from max_file_size config

Working:

SMTP
Screen.Recording.2022-05-30.at.3.51.26.PM.mov
IMAP
Screen.Recording.2022-05-30.at.3.54.02.PM.mov
POP3
Screen.Recording.2022-05-30.at.3.55.36.PM.mov

TODO:

  • docs
  • check if User Email doctype needs to consider this (?)

will hopefully close: #14815

docs:

@phot0n phot0n force-pushed the google_oauth_refactor branch 2 times, most recently from 42455b2 to 8ce1da7 Compare May 20, 2022 20:04
@codecov
Copy link

codecov bot commented May 23, 2022

Codecov Report

Merging #16935 (a292c7f) into develop (e762fe9) will increase coverage by 2.37%.
The diff coverage is 35.44%.

@@             Coverage Diff             @@
##           develop   #16935      +/-   ##
===========================================
+ Coverage    58.71%   61.09%   +2.37%     
===========================================
  Files          767      508     -259     
  Lines        68803    43768   -25035     
  Branches      6003        0    -6003     
===========================================
- Hits         40395    26738   -13657     
+ Misses       24918    17030    -7888     
+ Partials      3490        0    -3490     
Flag Coverage Δ
server 61.09% <35.44%> (-2.79%) ⬇️
ui-tests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

@phot0n phot0n added the Skip CI Doesn't run Ci for this PR. label May 24, 2022
@phot0n phot0n force-pushed the google_oauth_refactor branch 2 times, most recently from 971f79d to 300cdaf Compare May 27, 2022 05:53
@phot0n phot0n removed the Skip CI Doesn't run Ci for this PR. label May 27, 2022
@phot0n phot0n force-pushed the google_oauth_refactor branch 3 times, most recently from 4fb48cc to fc2db7a Compare May 30, 2022 08:27
@phot0n phot0n marked this pull request as ready for review May 30, 2022 08:52
@phot0n phot0n requested a review from a team May 30, 2022 08:52
@phot0n phot0n changed the title refactor: GoogleOAuth refactor!: GoogleOAuth May 30, 2022
@phot0n phot0n force-pushed the google_oauth_refactor branch 6 times, most recently from af45957 to 8dc24f8 Compare May 31, 2022 18:39
@phot0n
Copy link
Contributor Author

phot0n commented Jun 2, 2022

kinda don't like the UX - will update soon :P

frappe/email/oauth.py Outdated Show resolved Hide resolved
frappe/email/oauth.py Show resolved Hide resolved
frappe/email/oauth.py Outdated Show resolved Hide resolved
frappe/email/oauth.py Outdated Show resolved Hide resolved
res = self._connect_pop()

if not res.startswith(b"+OK"):
raise
Copy link
Collaborator

Choose a reason for hiding this comment

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

raising bare exception? Maybe we should log more info here.

Copy link
Contributor Author

@phot0n phot0n Jun 10, 2022

Choose a reason for hiding this comment

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

yep that's intentional ..it will get caught in the try except block for retrying/regenerating access token and if it again fails then we raise an OAuthenticationError

https://github.com/frappe/frappe/pull/16935/files#diff-0c840370456bfd1d0639a045bff918865f66d97116d7b05a7f9b06b1f1665232R76-R81

frappe/integrations/doctype/google_drive/google_drive.py Outdated Show resolved Hide resolved
@harshit-30
Copy link
Contributor

harshit-30 commented Jun 21, 2022

Any reason we haven't merged this yet? What's the ETA for this?

@gavindsouza @surajshetty3416 @phot0n

@phot0n
Copy link
Contributor Author

phot0n commented Jun 21, 2022

Any reason we haven't merged this yet? What's the ETA for this?

@harshit-30 This is my bad. Was on "kind of a break" the previous week - hence wasn't able to completely finish the pr (as you might've seen that there are some todo's pending).
Will Complete it within this week. Sorry for the delay.

phot0n added 18 commits July 13, 2022 12:05
* chore: raise not implemented error for services other than gmail

* chore: use fstring for _auth_string property
Since the places where connection methods are called already
have a lot of exception handling, we can just raise and let them
handle all the probable cases.
* minor: simplified validations for email account
@surajshetty3416 surajshetty3416 removed the add-docs New feature should be have an entry in documentation to increase the discoverability label Jul 13, 2022
@mergify mergify bot merged commit eb61357 into frappe:develop Jul 13, 2022
@phot0n phot0n deleted the google_oauth_refactor branch August 8, 2022 18:44
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OAuth 2.0 for email accounts
4 participants