-
Notifications
You must be signed in to change notification settings - Fork 31
Implemented XOAUTH2 authentication for POP3 #36
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
Conversation
PR Summary
|
TDannhauer
left a comment
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.
Looks good for me.
|
|
||
| case 'XOAUTH2': | ||
| if (!($xoauth2_token = $this->getParam('xoauth2_token'))) | ||
| throw new Horde_Imap_Client_Exception("Expected an XOAUTH2 token"); |
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.
If Horde_Imap_Client_Password_Xoauth2 is now used for IMAP as well as POP3, shouldn't the class be renamed/relocated to avoid confusion and fit poperly into the structure?
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.
@TDannhauer Hello Torben! I'm not sure I follow.
The library is named Horde_Imap, so all of the existing classes (including POP3) are already prefixed:
Horde_Imap_Client_Socket_Connection_Pop3Horde_Imap_Client_Socket_Pop3Horde_Imap_Client_Ids_Pop3
The password classes are:
Horde_Imap_Client_Base_PasswordHorde_Imap_Client_Password_Xoauth2
That feels consistent. The directory structure follows the class naming convention.
I do need to fix an XOAUTH2 protocol issue between Microsoft POP3 and Gmail POP3, though. The implementation uses a single line AUTH statement, but Microsoft only supports the two-line style (with the token on a second line).
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.
sorry missed that. Fine for me.
|
It looks like Microsoft POP3 requires a two-line Gmail POP3 is fine with either one-line or two-line. I'll update the PR to always use the two-line format. |
8932178 to
a260140
Compare
|
I updated the commit to always use the two-line |
Authentication with XOAUTH2 tokens was previously implemented for the IMAP protocol but not for POP3.
This PR implements the auth method for POP3 accounts.
Gmail supports XOAUTH2 tokens for both protocols:
This uses the same
xoauth2_tokenparameter as IMAP, and the sameHorde_Imap_Client_Password_Xoauth2class.In POP3, the command is
auth xoauth2 <base64-encoded auth-bearer>.This patch also moves XOAUTH2 to the first attempted authentication mechanism if the
xoauth2_tokenparameter is set; which makes USER with an app-specific password the optional fallback.