diff --git a/docs/clients.md b/docs/clients.md index 8216fc53c..0db3b928c 100644 --- a/docs/clients.md +++ b/docs/clients.md @@ -20,24 +20,10 @@ If you want to pre-approve your own web applications and prevent users in your a ### Creating the client id and secret keys -You can use the utility in `scripts/generate-client.js` to create new -ids and secrets. - -```sh -./scripts/generate-client.js config/prod.json -``` - -The utility will ask for various inputs related to the client, and then -generate an id and secret and store them in the config file for you. - -Then you can just start the OAuth server. The entry will be inserted automatically in your configured backend (i.e. database). - -```sh -CONFIG_FILES=config/prod.json NODE_ENV=prod grunt server -``` - -Last step is to give informations about your OAuth resource server to your clients. +Use the [fxa-oauth-client][] CLI tool for registering new clients with +your server. +[fxa-oauth-client]: https://github.com/mozilla/fxa-oauth-client ### OAuth resource server (a.k.a. `fxa-oauth-server`) diff --git a/scripts/generate-client.js b/scripts/generate-client.js deleted file mode 100644 index 4058c32d3..000000000 --- a/scripts/generate-client.js +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/bin/env node - -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -var fs = require('fs'); -var path = require('path'); - -var read = require('read'); - -var hash = require('../lib/encrypt').hash; -var unique = require('../lib/unique'); - - -var args = process.argv.slice(2); - -function p() { - console.log.apply(console, arguments); -} - -function r(schema, cb) { - var results = {}; - var name; - var prompts = Object.keys(schema); - - function prompt() { - name = prompts.shift(); - var opts = schema[name]; - if (!opts.prompt) { - opts.prompt = name + ':'; - } - read(opts, next); - } - - function next(err, result) { - if (err) { - return cb(err); - } - results[name] = result; - if (prompts.length) { - prompt(); - } else { - cb(null, results); - } - } - - prompt(); -} - -if (!args[0] || args[0].indexOf('-h') !== -1) { - p(''); - p('Usage: ./generate-client.js '); - p(''); - process.exit(0); -} - -var file = path.join(process.cwd(), args[0]); -if (!fs.existsSync(file)) { - p('Config file "%s" does not exist.', file); - process.exit(1); -} - -function yesno(val) { - if (typeof val === 'string') { - return val === 'y' || val === 'yes' || val === 't' || val === 'true'; - } else { - return !!val; - } -} - -var confJson = require(file); - - -p('This will help you generate a new client with credentials.'); -r({ - name: {}, - redirectUri: {}, - imageUri: {}, - canGrant: { - prompt: 'Implicit grant permission?', - default: 'false' - } -}, function(err, client) { - if (err) { - p(err); - process.exit(1); - } - client.id = unique.id().toString('hex'); - client.canGrant = yesno(client.canGrant); - - var secret = unique.secret(); - client.hashedSecret = hash(secret).toString('hex'); - client.trusted = true; - - p('About to write to %s:', file); - p(''); - p(JSON.stringify(client, null, 2)); - p(''); - read({ prompt: 'Is this ok?', default: 'yes'}, function(err, val) { - if (!yesno(val)) { - p('Aborted.'); - process.exit(0); - } - - var clients = confJson.clients || []; - clients.push(client); - confJson.clients = clients; - - fs.writeFileSync(file, JSON.stringify(confJson, null, 2)); - - p('Added client to clients array.'); - p(''); - p('Give these to the client:'); - p('(NOTICE) This is the raw secret. A hashed version was kept for you.'); - p(''); - p(' client_id:', client.id); - p(' client_secret:', secret.toString('hex')); - p(''); - }); -});