Skip to content

Commit

Permalink
Revert "change API_KEYS variable to be comma separated string as we'r…
Browse files Browse the repository at this point in the history
…e not using the JSON data at the mo and JSON causes issues in docker-compose.yml"

This reverts commit c24d919.
  • Loading branch information
Chris Impey committed Oct 5, 2015
1 parent 5de8d2f commit 94bad5c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module.exports = function (grunt) {
},
env: {
test: {
API_KEYS: '12345'
API_KEYS: '{"12345": "test-user"}'
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const plugins = [

let authKeys;
if (process.env.API_KEYS) {
authKeys = process.env.API_KEYS.split(',');
authKeys = JSON.parse(process.env.API_KEYS);
} else {
throw new Error('Environment variable API_KEYS not set');
}
Expand Down
6 changes: 3 additions & 3 deletions lib/token_auth_strategy.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

module.exports = function (keys) {
module.exports = function (keyData) {
return (token, callback) => {
if (keys.indexOf(token) >= 0) {
return callback(null, true, {token});
if (keyData[token]) {
return callback(null, true, {name: keyData[token], token});
}

callback(null, false);
Expand Down
4 changes: 2 additions & 2 deletions test/token_auth_strategy_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('token authenticator', () => {
let authenticator;

before(() => {
authenticator = authenticatorFactory('123456');
authenticator = authenticatorFactory({123456: 'bigwednesday.io'});
});

it('returns true when token is found', () => {
Expand All @@ -20,7 +20,7 @@ describe('token authenticator', () => {
it('returns credentials when token is found', () => {
authenticator('123456', (err, valid, credentials) => {
expect(err).not.to.be.ok;
expect(credentials).to.deep.equal({token: '123456'});
expect(credentials).to.deep.equal({name: 'bigwednesday.io', token: '123456'});
});
});

Expand Down

0 comments on commit 94bad5c

Please sign in to comment.