Commit graph

17 commits

Author SHA1 Message Date
Halla Moore d415e7792e [isomorphic-core] Ensure smtp config exists
Summary:
We previously weren't saving the smtp settings for cloud gmail accounts,
and even though we fixed that, we still need to be able to handle the accounts
that were authed before that fix went out. This diff changes `smtpConfig()` to
always call `credentialsForProvider` instead of depending on what was saved
in the database.

Test Plan: manual

Reviewers: juan, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D3980
2017-02-21 11:06:07 -08:00
Juan Tejada a0356ca76f [cloud-*] Add more detailed logs to auth endpoints
Summary: see title

Test Plan: manual, deploy to staging, check that it works

Reviewers: evan, spang, tomasz, khamidou

Reviewed By: tomasz

Differential Revision: https://phab.nylas.com/D3800
2017-01-27 11:48:06 -08:00
Christine Spang 933ebdfebb [iso-core] Split cert validation error handling off socket error handling
Summary:
Now that we don't do strict validation of certificates for non-major IMAP
providers this shouldn't come up as much, but when it does we're gonna
want a better error message to help support out.

I am not 100% sure there aren't other socket errors that should be fatal,
but this was the one I could figure out by test authing against a server
with a self-signed cert and grepping around the node socket source code.

Test Plan: manual

Reviewers: evan, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D3774
2017-01-25 09:45:20 -08:00
Evan Morikawa 02cf6fbf6e [isomorphic-core] have IMAP auth retry
Summary: IMAP auth retries

Test Plan: manual

Reviewers: khamidou, juan

Reviewed By: khamidou, juan

Differential Revision: https://phab.nylas.com/D3735
2017-01-18 17:29:58 -08:00
Juan Tejada 05fd276ec7 [cloud-api] Improve auth error logging 2017-01-18 13:36:50 -08:00
Halla Moore 6312c3a06b [iso-core] Use SUPPORTED_PROVIDERS in Account.smtpConfig()
Summary:
Consolidating provider checks to use the same source of truth.
Fixes send issues with some provider types.

Test Plan: tested locally

Reviewers: tomasz

Reviewed By: tomasz

Differential Revision: https://phab.nylas.com/D3694
2017-01-15 14:37:38 -08:00
Halla Moore c5453ca21b [iso-core] Let auth methods accept all supported providers
Summary: Treat any that aren't gmail or office365 as standard imap

Test Plan: manual

Reviewers: juan, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D3686
2017-01-14 17:35:09 -08:00
Evan Morikawa 4b7d3b4c2e [isomorphic-core] allow custom smtp configs 2017-01-14 14:47:15 -08:00
Evan Morikawa 5015d105b8 [isomorphic-core] fix sending on Office 365
Summary:
Fixed sending on Office 365
nodemailer needed a special tls flag beyond the standard SSL.
See: http://stackoverflow.com/questions/29812132/error-sending-email-using-nodemailer-via-office365-smtp-meanjs-scaffold

Test Plan: manual

Reviewers: juan, jackie, halla

Reviewed By: halla

Differential Revision: https://phab.nylas.com/D3541
2016-12-20 13:08:30 -08:00
Evan Morikawa d55a2af2cd [cloud-api] refactor cloud API routes to use es6 & fix Gmail Auth
Summary:
This is a refactor of the auth APIs to use async/await. Gmail Auth is
pretty confusing and I wanted to make it cleaner to read and easier to
use. This is also part of the general API upgrade to modern ES6

This also fixes the Gmail auth error we saw at showcase

Test Plan: manual

Reviewers: halla, jackie, mark, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D3535
2016-12-19 09:25:07 -08:00
Evan Morikawa d095551e90 [isomorphic-core] add office365 auth support
Summary:
Adds support for office 365
Depends on D3532

Test Plan: manual

Reviewers: jackie, halla, mark, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D3533
2016-12-16 16:53:05 -05:00
Karim Hamidou 101b99f4a7 [feat] Refresh Gmail access tokens when needed
Summary:
This is a small patch but it's pretty complex, because of the numbers of moving parts. Gmail has two types of tokens, access and refresh tokens. Access tokens have a limited shelf life of one hour. After that they expire and you need to use your refresh token to get a new one.

We've decided to do the access token generation on the server, because we don't feel comfortable giving our users both our Google client id and secret. To do that, I've added an endpoint, `/gmail/auth/refresh` which returns a valid access token as well as an expiration date for the token.

The only place where we handle token expiration is in the sync workers. Before trying opening a new connection we check if our access token is expired. If yes, we get a new one from the API. If there's an issue doing this, we notify N1 using `NylasAPIHelpers.handleAuthenticationFailure`.

There's a second patch for N1 with tiny related fixes.

Test Plan: Tested manually. Will need to test more in the real world.

Reviewers: evan, jackie, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D3522
2016-12-16 11:38:45 -08:00
Evan Morikawa edbf869ff7 [isomorphic-core] add more auth error states 2016-12-07 10:10:49 -08:00
Evan Morikawa 6ac46d1079 remove console log 2016-12-06 17:20:43 -08:00
Evan Morikawa 8cbda7505a [*] fix auth 2016-12-06 16:03:31 -08:00
Evan Morikawa 2cbb90bb3b [*] DRY Auth 2016-12-06 16:03:31 -08:00
Evan Morikawa 896f981408 [isomorphic-core] extract AuthHelpers to DRY 2016-12-06 16:03:31 -08:00