The orginal PR and it's forward ports https://github.com/odoo/odoo/pull/121048
intorduced an unexpected AttributeError when using OAuth for incoming
mail servers (fetchmail.server). Since `smtp_user` is not a defined field
in fetchmail.server (it uses the field `user` instead), we had to change
the approach.
To prevent this error, we move the UserError call into the respective
ir_mail_server models, which should check the contrains at that level.
This means that before the form gets saved, trying to connect using an
OAuth account, should prompt the user to first specify an smtp_user before
proceeding.
X-original-commit: fcfd72a5e5663fa6b08c80a8a22ec15c8a09456f
Original author: niyasraphy <niyasraphyk@gmail.com>
Conflict resolution for saas-15.2, 16.0, saas-16.2, saas-16.3
closesodoo/odoo#123660
X-original-commit: b0749e430847d2f49e07b119915e8dee0c4e7f00
Signed-off-by: Stéphane Debauche (std) <std@odoo.com>
Current behavior:
Connections for outgoing email servers using Outlook/Office365 or
Gmail accounts will establish an OAuth2 authentication for the smtp server.
Through the `ir_mail_server` form view, one can fetch the necessary
tokens by logging in into their Microsoft/Gmail account.
Not specifying an username (`smtp_user`) on the `ir_mail_server` record
will not produce an error while fetching those tokens.
But when trying to test the connection or use that server to send an email,
even if the FROM header is correctly set (i.e. the account email address
authorized to sent emails), the smtp connection will fail. This is due
to the fact that when `smtp_user == False`, the respective method
`_generate_outlook_oauth2_string` or respectively `_generate_oauth2_string`
will not be called and send the necessary OAuth2 string when sending
an email through the smtp connection.
This will lead to a `5.7.57 Client not authenticated to send mail.` error.
After this change:
Add specific UserErrors that get called if `smpt_user == False` before
the actions in `open_google_gmail_uri` and `open_microsoft_outlook_uri`
get called. This forces the user to input a `smpt_user` (field Username)
before the login page for OAuth2 gets called to fetch the tokens.
Note: there is no check if the user inputs the right username, only
that the field is not empty. So it is still possible to input an
invalid username.
opw-3268246
Conflict resolved for 16.0 forward port
Conflict resolved for 16.3 forward port
closesodoo/odoo#121764
X-original-commit: 65b0b876d98dad2aeda5f6ef965f6b7bb68e9424
Signed-off-by: Stéphane Debauche (std) <std@odoo.com>
Signed-off-by: jorv-odoo <jorv@odoo.com>
Purpose
=======
Allow to customize the Outlook endpoint to be able to use single
tenant apps.
Task-3053447
closesodoo/odoo#111821
X-original-commit: 4d62ac1838fc0bcebb779c90df9d80c2369e0d8a
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Signed-off-by: Stéphane Debauche (std) <std@odoo.com>
Every 90 days the imap auth needs to be done again, because that is the only
way the refresh token is updated. With this commit it is now done also when
a new access token is called.
closesodoo/odoo#109477
X-original-commit: b9ecb538b39e7d5467de141a515ac833ace02973
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Purpose
=======
Most of the time, both module will be installed at the same time, or
none. For that reason, we want to merge both modules into Microsoft Outlook.
Task-2811567
Part-of: odoo/odoo#88215
* fetchmail, google_gmail, fetchmail_gmail
Purpose
=======
Improve the usability of the outlook modules.
Specifications
==============
Remove the checkbox "Use Outlook" and instead use the
smtp_authentication and the server_type, to be consistent with Gmail.
Hide the password field for Outlook / Gmail mail servers.
Add constraints on the outgoing mail server to force the user to use
the right configuration (e.g. the from_filter, so the sending does not
fail).
Add an option in the mail module to install Outlook.
Show a message for the outgoing mail servers to explain each
authentication methods.
Task-2811567
Part-of: odoo/odoo#88215
Purpose
=======
If we want to deploy Outlook for a custom organization, it might be
useful to be able to customize the endpoint used in the API request.
For that purpose, we added a system parameter to overwrite the default
endpoint.
Task-2811567
Part-of: odoo/odoo#88215
Purpose
=======
As it has been done for Gmail, we want to add the OAuth authentication
for the incoming / outgoing mail server.
Specifications
==============
The user has to create a project on Outlook and fill the credentials
in Odoo. Once it's done, he can create an incoming / outgoing mail
server.
For the authentication flow is a bit different from Gmail. For Outlook
the user is redirected to Outlook where he'll accept the permission.
Once it's done, he's redirected again to the mail server form view and
the tokens are automatically added on the mail server.
Technical
=========
There are 3 tokens used for the OAuth authentication.
1. The authentication code. This one is only used to get the refresh
token and the first access token. It's the code returned by the user
browser during the authentication flow.
2. The refresh token. This one will never change once the user is
authenticated. This token is used to get new access token once they
are expired.
3. The access token. Those tokens have an expiration date (1 hour) and
are used in the XOAUTH2 protocol to authenticate the IMAP / SMTP
connection.
During the authentication process, we can also give a state that will
be returned by the user browser. This state contains
1. The model and the ID of the mail server (as the same mixin manage
both incoming and outgoing mail server)
2. A CSRF token which sign those values and is verified once the browser
redirect the user to the Odoo database. This is useful so a malicious
user can not send a link to an admin to disconnect the mail server.
Task-2751996
X-original-commit: 18dad5b13b0af81ef2089fc039b3a866a2895a53
Part-of: odoo/odoo#87731