Граф коммитов

251 Коммитов

Автор SHA1 Сообщение Дата
Phil Booth 02965a0b42 chore(project): pin rust to nightly-2018-06-10 2018-06-11 07:41:29 +01:00
Beatriz Rizental 49ed73cd34 fix(logging): add mozlog logging for requests
https://github.com/mozilla/fxa-email-service/pull/65
r=philbooth
2018-06-11 07:02:10 +01:00
Beatriz Rizental 50f8d523a4 fix(config): inject config in rocket managed state
https://github.com/mozilla/fxa-email-service/pull/66
r=philbooth
2018-06-10 22:46:07 +01:00
Phil Booth 5986e841ce fix(bounces): ensure db errors don't get converted to 429 responses (#59) r=@vladikoff 2018-06-07 21:37:43 -07:00
Phil Booth 44dcffd364
chore(project): remove the validator dependency
https://github.com/mozilla/fxa-email-service/pull/60
r=vladikoff
2018-06-06 12:42:18 +01:00
Phil Booth 145df00ffc chore(project): limit futures to < 0.2 (#58) r=@vladikoff 2018-06-05 17:16:02 -04:00
Beatriz Rizental 2beab89458 chore(project): loosen dependencies version numbers
https://github.com/mozilla/fxa-email-service/pull/57
r=philbooth
2018-06-05 21:50:02 +01:00
Phil Booth 008f119137 fix(validation): relax the sendgrid API key validation regex (#55) r=@vbudhram,@vladikoff 2018-06-05 15:45:09 -04:00
JR Conlin 66f5d5c049 fix(validation): allow RFC5321 compliant email addresses
email address validation is a pain, and you can use a surprising variety
of characters in an address.

(At least we're drawing the line at no quoted characters...)

Closes #44

https://github.com/mozilla/fxa-email-service/pull/45
r=philbooth
2018-06-05 18:35:27 +01:00
Phil Booth 7427318aaf refactor(queues): simplify lifetimes for queue objects 2018-06-05 18:35:27 +01:00
Phil Booth 6c154a04f8 feat(queues): return futures instead of blocking for queue handling 2018-06-05 18:35:27 +01:00
Phil Booth 4b05fd3dc3 chore(queues): marshall SES notifications to our own generic type 2018-06-05 18:35:27 +01:00
Phil Booth 4338f24cbe feat(queues): handle SES bounce, complaint and delivery notifications
A direct mapping of functionality from the auth server, so the different
notification types are expected on three different queues. Long-term it
makes sense to simplify that down to a single queue, but this way we can
ease the new service in alongside the existing auth server.

As a first cut, the methods on queues::sqs::Queue all block the thread
in this implementation. A subsequent change will transition to futures.
2018-06-05 18:35:27 +01:00
Phil Booth f18a5bc60e
chore(code): eliminate some if-lets in favour of combinators
https://github.com/mozilla/fxa-email-service/pull/43
r=vladikoff
2018-06-05 13:23:01 +01:00
Phil Booth bc62a046d7 chore(project): delete errant src/queues/sendgrid/mod.rs
Accidentally added as part of fe8ec12 when I switched branches from the
in-progress Sengrid queue implementation and did `git add .`.
2018-06-05 09:51:23 +01:00
Phil Booth fe8ec12f55
fix(sendgrid): return message id from the sendgrid provider
https://github.com/mozilla/fxa-email-service/pull/37
r=rfk,shane-tomlinson
2018-06-05 09:15:40 +01:00
Phil Booth 82acb10ed6
chore(errors): don't serialize nulls in error payloads
https://github.com/mozilla/fxa-email-service/pull/39
r=shane-tomlinson
2018-06-04 12:34:33 +01:00
Phil Booth b5343d54b2
fix(errors): return JSON payloads for error responses
https://github.com/mozilla/fxa-email-service/pull/36
r=vbudhram
2018-06-01 18:25:11 +01:00
Phil Booth 1d5d100d20
chore(project): update rocket, unpin from nightly-2018-05-29 2018-06-01 10:24:13 +01:00
Phil Booth 25947a96d7
feat(sendgrid): implement basic sending via sendgrid
https://github.com/mozilla/fxa-email-service/pull/34
r=vbudhram
2018-05-31 17:31:14 +01:00
Phil Booth e114385c03
chore(project): cargo update + pin to nightly-2018-05-29
Rocket 0.3.11 doesn't compile in Rust nightly-2018-05-30.
2018-05-31 10:03:11 +01:00
Phil Booth fc612632e3
chore(queues): split out a separate process for queue-handling
https://github.com/mozilla/fxa-email-service/pull/32
r=rfk
2018-05-29 09:01:54 +01:00
Phil Booth ca44a94b8d
feat(db): implement AuthDb::create_bounce
https://github.com/mozilla/fxa-email-service/pull/31
r=rfk
2018-05-29 08:20:34 +01:00
Phil Booth 58bf9bec33
fix(errors): include more useful messages in wrapping errors
Error types commonly print the most helpful information via the Debug
trait, which can be accessed using the {:?} format specifier. This
change just ensures we propagate that more useful information when
wrapping other error types.

https://github.com/mozilla/fxa-email-service/pull/30
r=rfk
2018-05-28 22:46:50 +01:00
Phil Booth fa796dfe03
fix(db): fix broken BounceSubtype deserialization
I was missing some tests for BounceSubtype deserialization, which meant
I hadn't realised that the derived implementation of Deserialize was
mapping values to strings rather than numbers. This change fixes that
and adds the corresponding test coverage.

https://github.com/mozilla/fxa-email-service/pull/29
r=rfk
2018-05-28 22:43:47 +01:00
Phil Booth 848890b907 refactor(db): rename get_email_bounces => get_bounces 2018-05-24 06:55:52 +01:00
Phil Booth da70321dc2 fix(db): add missing derive(Debug) 2018-05-24 06:55:52 +01:00
Phil Booth 79e0ea314c fix(db): add missing fields/values to auth_db::BounceRecord 2018-05-24 06:55:52 +01:00
Phil Booth 00b536321f chore(project): rustup update + cargo update + cargo fmt 2018-05-18 14:59:42 +01:00
Phil Booth b716e04abb chore(ci): disable ci on non-master branches 2018-05-18 14:28:10 +01:00
Phil Booth 798d534b0b chore(docs): fix license link 2018-05-16 08:37:05 +01:00
Phil Booth 39877b45da chore(project): inch closer towards the default rustfmt config 2018-05-16 08:34:54 +01:00
Phil Booth 5fd4e6aafd feat(docs): add a readme doc 2018-05-16 07:37:00 +01:00
Phil Booth 579bca8c5b chore(config): run rocket on port 8001 in dev 2018-05-16 06:57:23 +01:00
Phil Booth 490a69e100
feat(db): check the emailBounces table before sending email
Loads bounce limits from config and then checks email addresses against
those limits before sending the email. If any address violates a limit,
the request will fail with status 429 and email will not be sent.

As it introduces a dependency on the fxa-auth-db-mysql repo, some extra
scripting has been thrown in to make working with node.js easier.

Running `./tdb` will check whether an `fxa-auth-db-mysql` directory
exists and, if not, clone the repo. Then it will check for running db
server processes and, if none are found, run `npm i`, run the db patcher
and start the db server in a background process. Then it finishes by
invoking the existing `./t` script.

This is not ideal because it leaves the node process running in the
background after tests have finished. But I figure it's good enough for
now because it only leaves one of them running, they don't multiply with
subsequent test runs. And you don't have to use the new script of
course, if you already have the db server running in fxa-local-dev, you
can just run `./t` and the tests should pass. The new script is mostly
there for Travis' benefit.

https://github.com/mozilla/fxa-email-service/pull/22
r=rfk,vbudhram
2018-05-16 05:25:08 +01:00
Phil Booth 17a36759ec chore(project): update regex dependency 2018-05-08 09:19:30 +01:00
Phil Booth 451702121a chore(tests): remove mutex hack 2018-05-08 07:47:38 +01:00
Phil Booth da3cdf69fd feat(ses): add support for aws access and secret keys 2018-05-08 07:47:38 +01:00
Phil Booth 4ab1d9ce03 feat(ses): implement basic ses-based email sending 2018-05-08 07:47:38 +01:00
Phil Booth 106edd8e2b chore(project): update rocket and unpin from nightly-2018-04-28 2018-05-05 09:37:43 +01:00
Phil Booth c08434beb9 chore(project): add the MPL 2018-05-04 07:14:43 +01:00
Phil Booth f7dd71456e
refactor(settings): extract common functions for deserialization
Extracts the inline validation code from the settings module to a
dedicated deserialize module, so that the validation rules can be better
re-used elsewhere.

Uses functions rather than newtype structs, for 2 reasons:

1. There's an issue in the config crate where newtype structs aren't
   deserialized. An unmerged PR exists to fix it, but in the meantime
   this changeset works round the problem.

2. When using newtype structs, the tests aren't able to create fresh
   instances of the Settings struct unless it is flattened to a single
   level.

Maybe we can revisit the newtype struct approach down the line when both
of the above are resolved.

https://github.com/mozilla/fxa-email-service/pull/15
r=rfk
2018-05-04 06:27:33 +01:00
Phil Booth 04e33b0afc chore(ci): fix to rust nightly 2018-04-28
Related to https://github.com/SergioBenitez/Rocket/pull/624
2018-05-03 17:28:39 +01:00
Phil Booth a86015fb49 feat(config): add configuration
Imitates, as closely as possible, the convict-based approach we use in
our node repos. The major difference is that validation here has to
happen in the code, we can't define it in config.

Settings are applied in the following order:

* config/default.json
* config/${NODE_ENV}.json (optional)
* config/local.json (optional, git-ignored)
* environment variables

I opted to re-use $NODE_ENV instead of some rust-specific environment
variable so that our dev setups will work with minimal changes. If that
seems too weird though I can change it.

Uses the `config` crate, which was the convictiest dependency I could
find.
2018-04-30 18:54:48 +01:00
Phil Booth 4d1a265c40 chore(project): turn off reorder_impl_items rustfmt setting 2018-04-29 08:15:11 +01:00
Phil Booth 13ffd01594 chore(project): revert a bunch of custom rustfmt settings 2018-04-27 11:30:20 +01:00
Phil Booth b6dad7217c fix(api): limit `to` field to a single recipient 2018-04-27 11:30:20 +01:00
Phil Booth 6c3361c2a1 feat(api): implement a basic /send endpoint
Not wired in to any behaviour, just does some crude validation and then
returns a hard-coded message id. There is some test coverage, but also
some gaps where I haven't figured out how we should do stuff yet:

* The validation code is punishingly verbose. I evauated a couple of
  crates to implement validation, `accord` and `validator`, and opted
  for `validator`. However they both seem quite simple, for instance
  there's no support for nested objects or values packed inside arrays.
  This meant we couldn't lean on the nice, readable macro syntax that's
  available and have to explitly validate fields using Rocket's FromData
  trait instead.

* Rocket has a feature called error catchers, which I couldn't get to
  work. These are supposed to let you return custom error data but, no
  matter what I tried, it always seemed to return the default error
  response for each type (which is an html string). And even if I could
  get those to work, I couldn't see a way to propagate rich error
  information, e.g. names of invalid parameters, into the catcher
  without having to validate all of the parameters a second time inside
  the catcher.

* I tried to write a test case that fired unicode at the endpoint and it
  failed.

I'm sure the root cause of these problems is just my own lack of
expertise and we'll figure it out eventually. In the meantime, this
seemed like enough to get us started. I'll open issues to cover the
above.

In terms of code structure, I've just lumped most stuff in to the send
module for now. As we add more functionality, I expect the natural
boundaries to reveal themselves. No point agonising over it yet.
2018-04-27 11:30:20 +01:00
Phil Booth b616c36ca3 chore(project): add ci config 2018-04-25 15:40:51 +01:00
Phil Booth a7b1f51013 chore(project): add rocket dependency 2018-04-25 10:27:43 +01:00