Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Commit

Permalink
revert(service-tokens): Revert "feat(tokens): allow using JWT grants …
Browse files Browse the repository at this point in the history
…from Service Clients"

This reverts commit 0a0e303.
  • Loading branch information
rfk committed Oct 28, 2015
1 parent 6be9ac2 commit d3cc78a
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 381 deletions.
2 changes: 1 addition & 1 deletion config/test.json
Expand Up @@ -54,7 +54,7 @@
{
"id": "d23dbf62b82eb04e",
"name": "Test Service Client",
"scope": "profile",
"scope": "profile:email",
"jku": "http://127.0.0.1:9019/.well-known/public-keys"
}
]
Expand Down
31 changes: 2 additions & 29 deletions lib/db/index.js
Expand Up @@ -12,7 +12,6 @@ const env = require('../env');
const logger = require('../logging')('db');
const klass = config.get('db.driver') === 'mysql' ?
require('./mysql') : require('./memory');
const unique = require('../unique');

function clientEquals(configClient, dbClient) {
var props = Object.keys(configClient);
Expand Down Expand Up @@ -109,32 +108,6 @@ function preClients() {
}
}

function serviceClients() {
var clients = config.get('serviceClients');
if (clients && clients.length) {
logger.debug('serviceClients.loading', clients);

return P.all(clients.map(function(client) {
return exports.getClient(client.id).then(function(existing) {
if (existing) {
logger.verbose('seviceClients.existing', client);
return;
}

return exports.registerClient({
id: client.id,
name: client.name,
hashedSecret: encrypt.hash(unique.secret()),
imageUri: '',
redirectUri: '',
trusted: true,
canGrant: false
});
});
}));
}
}

var driver;
function withDriver() {
if (driver) {
Expand All @@ -149,7 +122,7 @@ function withDriver() {
return p.then(function(store) {
logger.debug('connected', { driver: config.get('db.driver') });
driver = store;
}).then(exports._initialClients).then(function() {
}).then(preClients).then(function() {
return driver;
});
}
Expand Down Expand Up @@ -187,5 +160,5 @@ exports.disconnect = function disconnect() {
};

exports._initialClients = function() {
return preClients().then(serviceClients);
return preClients();
};
4 changes: 2 additions & 2 deletions lib/db/mysql/index.js
Expand Up @@ -363,8 +363,8 @@ MysqlStore.prototype = {
},
generateAccessToken: function generateAccessToken(vals) {
var t = {
clientId: buf(vals.clientId),
userId: buf(vals.userId),
clientId: vals.clientId,
userId: vals.userId,
email: vals.email,
scope: Scope(vals.scope),
token: unique.token(),
Expand Down
5 changes: 0 additions & 5 deletions lib/db/mysql/patches/patch-010-011.sql

This file was deleted.

5 changes: 0 additions & 5 deletions lib/db/mysql/patches/patch-011-010.sql

This file was deleted.

2 changes: 1 addition & 1 deletion lib/db/mysql/schema.sql
Expand Up @@ -41,7 +41,7 @@ CREATE TABLE IF NOT EXISTS tokens (
FOREIGN KEY (clientId) REFERENCES clients(id) ON DELETE CASCADE,
userId BINARY(16) NOT NULL,
INDEX tokens_user_id(userId),
email VARCHAR(256),
email VARCHAR(256) NOT NULL,
type VARCHAR(16) NOT NULL,
scope VARCHAR(256) NOT NULL,
createdAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
Expand Down
6 changes: 5 additions & 1 deletion lib/routes/authorization.js
Expand Up @@ -99,7 +99,11 @@ module.exports = {
validate: {
payload: {
client_id: validators.clientId,
assertion: validators.assertion
assertion: Joi.string()
// taken from mozilla/persona/lib/validate.js
.min(50)
.max(10240)
.regex(/^[a-zA-Z0-9_\-\.~=]+$/)
.required(),
redirect_uri: Joi.string()
.max(256),
Expand Down

0 comments on commit d3cc78a

Please sign in to comment.