Skip to content
Snippets Groups Projects
Commit a434f923 authored by Lloyd Hilaiel's avatar Lloyd Hilaiel
Browse files

make userdb more real: users have any number of 'contexts' that correspond to...

make userdb more real: users have any number of 'contexts' that correspond to different devices.  key material is device scoped.
parent c6c0196b
No related branches found
No related tags found
No related merge requests found
......@@ -4,28 +4,25 @@ userdb = require("./user_db.js");
// lets create a user!
// we'll need a cookie jar (client context)
var ctx = {};
// and a configuration (what server we're talking to)
var cfg = { browserid: 'http://127.0.0.1:10002' }
// and a user
var user = userdb.getNewUser();
userdb.addKeyToUser(user);
userdb.addKeyToUserCtx(user.ctxs[0]);
// now start the dance with a call to stage_user
wcli.post(cfg, '/wsapi/stage_user', ctx, {
wcli.post(cfg, '/wsapi/stage_user', user.ctxs[0], {
email: user.emails[0],
pass: user.password,
pubkey: user.pubkeys[0],
pubkey: user.ctxs[0].keys[0].pub,
site: user.sites[0]
}, function (r) {
// now get the verification secret
wcli.get(cfg, '/wsapi/fake_verification', ctx, {
wcli.get(cfg, '/wsapi/fake_verification', user.ctxs[0], {
email: user.emails[0]
}, function (r) {
wcli.get(cfg, '/wsapi/prove_email_ownership', ctx, {
wcli.get(cfg, '/wsapi/prove_email_ownership', user.ctxs[0], {
token: r.body
}, function (r) {
console.log(r.body);
......
......@@ -63,8 +63,18 @@ exports.getNewUser = function() {
secrets.generate(8) + "." + secrets.generate(3),
secrets.generate(8) + "." + secrets.generate(3)
],
// and no public keys (XXX: beware the cometh of certs)
pubkeys: [
// and their device contexts (they have 2 devices on average)
// key material is device specific
ctxs: [
{
// and no public keys (XXX: beware the cometh of certs)
keys: [
]
},
{
keys: [
]
}
]
};
users.push(user);
......@@ -82,8 +92,13 @@ exports.addEmailToUser = function(user) {
return email;
};
exports.addKeyToUser = function(user) {
var key = secrets.generate(128);
user.pubkeys.push(key);
return key;
exports.addKeyToUserCtx = function(ctx) {
// this is simulated. it will need to be real to apply load to
// the verifier, but that in turn will drastically increase the
// cost of the application of load. ho hum.
var pub = secrets.generate(128);
var priv = secrets.generate(128);
var k = {pub: pub, priv: priv}
ctx.keys.push(k);
return k;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment