DEPRECATED - Migrated to https://github.com/mozilla/fxa
Перейти к файлу
hritvi 1b910f0af9 refactor(fxa-auth-server): Added semicolons(semi rule) 2019-03-26 11:09:35 +05:30
.circleci chore(deploy): upgrade to node 10 2019-02-20 14:35:29 +00:00
bin refactor(fxa-auth-server): Added semicolons(semi rule) 2019-03-26 11:09:35 +05:30
config refactor(fxa-auth-server): Added semicolons(semi rule) 2019-03-26 11:09:35 +05:30
docs chore(docs): disable the auto-generated api docs script 2019-03-25 20:33:11 +00:00
fxa-oauth-server feat(devices): devices API with refreshTokens 2019-03-19 11:00:04 -04:00
grunttasks refactor(fxa-auth-server): Added semicolons(semi rule) 2019-03-26 11:09:35 +05:30
lib refactor(fxa-auth-server): Added semicolons(semi rule) 2019-03-26 11:09:35 +05:30
scripts refactor(fxa-auth-server): Added semicolons(semi rule) 2019-03-26 11:09:35 +05:30
test refactor(fxa-auth-server): Added semicolons(semi rule) 2019-03-26 11:09:35 +05:30
.dockerignore refactor(oauth): combine oauth deps and package.json with auth 2018-12-12 19:12:37 -05:00
.eslintrc refactor(fxa-auth-server): Added semicolons(semi rule) 2019-03-26 11:09:35 +05:30
.gitignore refactor(l10n): take l10n repo out of node_modules (#2079) 2017-09-06 09:33:19 -04:00
.nsprc chore(package): disable security advisory 766 for sandbox dependency 2019-01-16 11:17:07 +00:00
.travis.yml chore(deploy): upgrade to node 10 2019-02-20 14:35:29 +00:00
AUTHORS chore(docs): update AUTHORS list (#2024) 2017-07-27 16:26:02 -04:00
CHANGELOG.md Release v1.133.1 2019-03-19 11:16:02 -04:00
CONTRIBUTING.md docs(contributing): Mention git commit guidelines 2016-01-21 12:24:41 +01:00
Dockerfile-build feat(devices): devices API with refreshTokens 2019-03-19 11:00:04 -04:00
Dockerfile-oauth-build chore(deploy): upgrade to node 10 2019-02-20 14:35:29 +00:00
Dockerfile-oauth-test refactor(oauth): combine oauth deps and package.json with auth 2018-12-12 19:12:37 -05:00
Dockerfile-test fix(npm): use npm ci for npm install 2018-09-19 13:58:04 -04:00
Gruntfile.js refactor(fxa-auth-server): Added semicolons(semi rule) 2019-03-26 11:09:35 +05:30
LICENSE Add a proper copy of the MPL 2014-05-16 17:27:17 +12:00
README.md chore(api): remove metrics context data from deprecated endpoints 2018-10-25 17:18:07 +01:00
npm-shrinkwrap.json fix(deps): fix npm advisory 788 2019-03-23 11:38:28 -04:00
package.json chore(docs): disable the auto-generated api docs script 2019-03-25 20:33:11 +00:00

README.md

Firefox Accounts Server

Build Status Coverage Status CircleCI Code Quality: Javascript Total Alerts

This project implements the core server-side API for Firefox Accounts. It provides account, device and encryption-key management for the Mozilla Cloud Services ecosystem.

Overview

Detailed design document

Detailed API spec

Guidelines for Contributing

Prerequisites

  • node 6+
  • npm 2
  • Grunt
  • postfix
  • memcached
  • redis

Install

On some systems running the server as root will cause working directory permissions issues with node. It is recommended that you create a separate, standard user to ensure a clean and more secure installation.

Clone the git repository and install dependencies:

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

To start the server in dev memory store mode (ie. NODE_ENV=dev), run:

npm start

This runs a script scripts/start-local.sh as defined in package.json. This will start up 4 services, three of which listen on the following ports (by default):

  • bin/key_server.js on port 9000
  • test/mail_helper.js on port 9001
  • ./node_modules/fxa-customs-server/bin/customs_server.js on port 7000

When you Ctrl-c your server, all 4 processes will be stopped.

To start the server in dev MySQL store mode (ie. NODE_ENV=dev), run:

npm run start-mysql

Testing

Run tests with:

npm test

To select a specific glob of tests to run:

npm test -- test/local/account_routes.js test/local/password_*
  • Note: stop the auth-server before running tests. Otherwise, they will fail with obscure errors.
  • You can use LOG_LEVEL, such as LOG_LEVEL=debug to specify the test logging level.

Mailer

The mailer library is located in mailer/ directory.

The emails are written to postfix which tends sends them off to SES.

The auth-mailer also includes a restify API to send emails, but the auth server is using it as a library at the moment.

Changing Templates

If you are changing or adding templates then you need to update .html and .txt templates. In mailer/, use the /partials directory to make changes to the HTML templates, then run grunt templates to regenerate the template. This saves the HTML template into /templates. Then make changes to the .txt template in the /templates directory.

L10N

After updating a string in one of the templates in ./mailer/templates you'll need to extract the strings. Follow the instructions at mozilla/fxa-content-server-l10n.

Production

Use the FXA_L10N_SHA to pin L10N files to certain SHA. If not set then the master SHA will be used.

Reference Client

https://github.com/mozilla/fxa-js-client

Dev Deployment

Refer to https://github.com/mozilla/fxa-dev.git.

Configuration

Configuration of this project is managed by convict, using the schema in config/index.js.

Default values from this schema can be overridden in two ways:

  1. By setting individual environment variables, as indicated by the env property for each item in the schema.

    For example:

    export CONTENT_SERVER_URL="http://your.content.server.org"
    
  2. By specifying the path to a conforming JSON file, or a comma-separated list of paths, using the CONFIG_FILES environment variable. Files specified in this way are loaded when the server starts. If the server fails to start, it usually indicates that one of these JSON files does not conform to the schema; check the error message for more information.

    For example:

    export CONFIG_FILES="~/fxa-content-server.json,~/fxa-db.json"
    

Email config

There is also some live config loaded from Redis for the email service. This config is stored as a JSON string that looks like this (every property is optional):

{
  "sendgrid": {
    "percentage": 100,
    "regex": "^.+@example\\.com$"
  },
  "socketlabs": {
    "percentage": 100,
    "regex": "^.+@example\\.org$"
  },
  "ses": {
    "percentage": 10,
    "regex": ".*"
  }
}

scripts/email-config.js has been written to help manage this config.

  • To print the current live config to stdout:

    node scripts/email-config read
    
  • To set the live config from a JSON file on disk:

    cat foo.json | node scripts/email-config write
    
  • To set the live config from a string:

    echo '{"sendgrid":{"percentage":10}}' | node scripts/email-config write
    
  • To undo the last change:

    node scripts/email-config revert
    
  • To check the resolved config for a specific email address:

    node scripts/email-config check foo@example.com
    

Troubleshooting

Firefox Accounts authorization is a complicated flow. You can get verbose logging by adjusting the log level in the config.json on your deployed instance. Add a stanza like:

"log": {
  "level": "trace"
}

Valid level values (from least to most verbose logging) include: "fatal", "error", "warn", "info", "trace", "debug".

Database integration

This server depends on a database server from the fxa-auth-db-mysql repo. When running the tests, it uses a memory-store that mocks behaviour of the production MySQL server.

License

MPL 2.0