-
Notifications
You must be signed in to change notification settings - Fork 43
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
Add XOAUTH2 authentication #152
Conversation
This implementation accepts the OAuth token when `mailmerge` prompts for a password. To use this OAuth authentication, the `mailmerge_server.conf` should use `XOAUTH` for security, e.g. ``` [smtp_server] host = smtp.office365.com port = 587 security = XOAUTH username = me@example.com ``` This implementation assumes that an OAuth token has already been obtained by 3rd party tool using the tenant_id, client_id and client_secret. The OAuth integration implemented in this commit encodes the username and OAuth token in base 64 in SASL XOAUTH2 format. For reference about this SASL XOAUTH2 encoding, see: https://learn.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth#sasl-xoauth2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great addition! I left a question about encodings.
Would you be willing to add a test? You could copy paste test_security_starttls
as a starting point.
Yes, without
I've added exception handling here: 7f31846
I'm unfamiliar with Python tooling, so I'm unsure how to run the existing tests.
|
Thanks for adding the exception handling. To install deps and run the unit tests check out these commands. You don't need to add anything to a list, just copy paste an old test, change the name, and modify the code a bit. |
Codecov ReportPatch coverage:
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. Additional details and impacted files@@ Coverage Diff @@
## develop #152 +/- ##
===========================================
+ Coverage 99.72% 99.74% +0.02%
===========================================
Files 5 5
Lines 358 386 +28
===========================================
+ Hits 357 385 +28
Misses 1 1
☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a bit of refactoring to satisfy the linter. The addition of the XOAUTH code had made the enclosing function too complicated, so I split it up. I also added a check to the unit test to verify the formatting of the username/password string.
Would you be able to test this updated code on a real server just to be extra sure?
@awdeorio I've tested this branch with your latest commits, against smtp.office365.com on port 587. It sends emails as expected, so I think we're good to go. |
Great! Merging! |
Adds OAuth based authentication.
Fixes #150