Skip to content
Snippets Groups Projects
  1. May 26, 2023
    • jorv's avatar
      [FIX] google_gmail, microsoft_outlook : move UserError to ir_mail_server · 68b76c2f
      jorv authored
      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: fcfd72a5
      Original author: niyasraphy <niyasraphyk@gmail.com>
      Conflict resolution for saas-15.2, 16.0
      
      closes odoo/odoo#122613
      
      X-original-commit: 3de5e2a1a0238b3edc5537aa5e3842ad5430a186
      Signed-off-by: default avatarStéphane Debauche (std) <std@odoo.com>
      68b76c2f
  2. May 23, 2023
  3. May 17, 2023
    • jorv's avatar
      [FIX] microsoft_outlook,google_gmail: require username for OAuth2 · b00633f1
      jorv authored
      
      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
      
      closes odoo/odoo#121541
      
      X-original-commit: 0f6602c7
      Signed-off-by: default avatarStéphane Debauche (std) <std@odoo.com>
      Signed-off-by: default avatarjorv-odoo <jorv@odoo.com>
      b00633f1
  4. Sep 20, 2022
  5. Jun 10, 2022
  6. Apr 01, 2022
    • std-odoo's avatar
      [ADD] fetchmail_outlook, microsoft_outlook: add OAuth authentication · bcdf9e12
      std-odoo authored
      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
      bcdf9e12
Loading