DEPRECATED - Migrated to https://github.com/mozilla/fxa
fxa
Перейти к файлу
Peter deHaan dad97a5124 chore(build): Replace JSHint with ESLint 2015-06-29 17:20:42 -07:00
bans feat(config): Add a badLoginLockoutIntervalSeconds configuration option. 2015-03-10 10:10:46 +00:00
bin feat(config): Add a badLoginLockoutIntervalSeconds configuration option. 2015-03-10 10:10:46 +00:00
config chore(config): Update convict and switch on strict validation. 2015-06-10 12:31:08 +10:00
docs Document the API 2014-09-29 17:21:32 -07:00
grunttasks chore(build): Replace JSHint with ESLint 2015-06-29 17:20:42 -07:00
scripts chore(travis): quiet validate-shrinkwrap failure on security warning on module 2015-04-16 17:47:38 -07:00
test chore(build): Replace JSHint with ESLint 2015-06-29 17:20:42 -07:00
.awsbox.json Actually address the typo that Andy found 2014-06-27 15:05:27 +12:00
.eslintrc chore(build): Replace JSHint with ESLint 2015-06-29 17:20:42 -07:00
.gitignore Enable test coverage analysis using ass (fix #4) 2014-05-08 20:02:11 +12:00
.travis.yml chore(travis): quiet validate-shrinkwrap failure on security warning on module 2015-04-16 17:47:38 -07:00
CHANGELOG Release v0.39.0 2015-06-10 15:59:34 -07:00
CONTRIBUTING.md Customize README and CONTRIBUTING for this repo 2014-05-21 16:53:29 +12:00
Gruntfile.js chore(build): Replace JSHint with ESLint 2015-06-29 17:20:42 -07:00
LICENSE Add a copy of the MPL and put tests in Public Domain 2014-05-06 16:28:34 +12:00
README.md feat(docs): Include a snipped about the memcached requirement. 2015-02-26 13:26:52 +00:00
email_record.js Merge pull request #76 from shane-tomlinson/issue-75-bad-login-interval 2015-03-17 09:42:52 +11:00
ip_email_record.js Rename isIpEmailAction() to isPasswordCheckingAction() 2015-02-13 16:57:00 +11:00
ip_record.js Add .shouldBlock() and .isRateLimited(); normalise .isBlocked() and .update() 2014-10-15 17:26:58 +13:00
log.js first commit 2014-04-18 17:02:32 -07:00
npm-shrinkwrap.json chore(build): Replace JSHint with ESLint 2015-06-29 17:20:42 -07:00
package.json chore(build): Replace JSHint with ESLint 2015-06-29 17:20:42 -07:00

README.md

Firefox Accounts Customs Server

Build Status

This project is used by the Firefox Accounts Auth Server to detect and deter fraud and abuse.

Prerequisites

  • node 0.10.x
  • npm
  • memcached
    • On Debian flavors of Linux: sudo apt-get install memcached
    • On Mac OS X: brew install memcached

Install

Clone the git repository and install dependencies:

git clone git://github.com/mozilla/fxa-customs-server.git
cd fxa-customs-server
npm install

To start the server, run:

npm start

It will listen on http://127.0.0.1:7000 by default.

Testing

Run tests with:

npm test

On Mac OS X, memcached must be manually started for the tests to run.

memcached &
npm test

Code

Here are the main components of this project:

  • bans/: code implementing temporary bans of specific email or IP addresses and listening on the SQS API for requests
  • bin/customs_server.js: process listening on the network and responding to HTTP API calls
  • config/config.js: where all of the configuration options are defined
  • email_record.js, ip_email_record.js and ip_record.js: code implementing the various blocking and rate-limiting policies
  • scripts: helper scripts only used for development/testing
  • test/local: unit tests
  • test/remote: tests exercising the HTTP API

API

See our detailed API spec.

Policies

There are three types of policies:

  • rate-limiting: slows down attackers by temporarily blocking requests for 15 minutes (see config.limits.rateLimitIntervalSeconds)
  • block / ban: stops attacks by temporarily blocking requests for 24 hours (see config.limits.blockIntervalSeconds)
  • lockout: stops password-guessing attacks by permanently blocking password-authenticated requests until the user reconfirms their email address by clicking a link

We currently have the following policies in place:

  • rate-limiting when too many emails (config.limits.maxEmails defaults to 3) have been sent to the same email address in a given time period (config.limits.rateLimitIntervalSeconds defaults to 15 minutes)
  • rate-limiting when too many failed login attempts (config.limits.maxBadLogins defaults to 2) have occurred for a given account and IP address, in a given time period (config.limits.rateLimitIntervalSeconds defaults to 15 minutes)
  • lockout when too many failed login attempts (config.limits.badLoginLockout defaults to 20) have occurred for a given account regardless of the IP address, in a given time period (config.limits.rateLimitIntervalSeconds defaults to 15 minutes)
  • manual blocking of an account (see /blockEmail API call)
  • manual blocking of an IP address (see /blockIp API call)

The data that these policies are based on is stored in a memcache instance (keyed by email, ip or ip + email depending on the policy) and the code that implements them is split across these three files:

  • email_record.js handles blocking and rate-limiting based only on the email address
  • ip_email_record.js handles rate-limiting based on both the email and IP address of the request
  • ip_record.js handles blocking based only on the IP address

The rate-limiting and blocking policies are conveyed to the auth server via the block property in the response to /check wheres the lockout policies are conveyed via the response to /failedLoginAttempt.