2013-05-16 00:42:25 +04:00
|
|
|
/* 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/. */
|
|
|
|
|
2014-08-28 22:19:08 +04:00
|
|
|
var b64 = require('jwcrypto/lib/utils').base64urlencode
|
|
|
|
var bigint = require('bigint')
|
|
|
|
|
2013-10-27 06:02:54 +04:00
|
|
|
module.exports = function (log, serverPublicKey) {
|
2013-05-15 03:23:36 +04:00
|
|
|
|
2013-07-23 22:16:44 +04:00
|
|
|
var routes = [
|
|
|
|
{
|
|
|
|
method: 'GET',
|
|
|
|
path: '/.well-known/browserid',
|
2014-03-01 03:37:53 +04:00
|
|
|
config: {
|
|
|
|
cache: {
|
|
|
|
privacy: 'public',
|
|
|
|
expiresIn: 10000
|
|
|
|
}
|
|
|
|
},
|
2014-08-23 05:06:34 +04:00
|
|
|
handler: function browserid(request, reply) {
|
|
|
|
log.begin('browserid', request)
|
2014-02-01 07:36:25 +04:00
|
|
|
reply(
|
|
|
|
{
|
|
|
|
'public-key': serverPublicKey,
|
|
|
|
'authentication': '/.well-known/browserid/sign_in.html',
|
|
|
|
'provisioning': '/.well-known/browserid/provision.html'
|
|
|
|
}
|
|
|
|
)
|
2013-05-16 00:42:25 +04:00
|
|
|
}
|
2013-07-23 22:16:44 +04:00
|
|
|
},
|
2014-08-23 05:06:34 +04:00
|
|
|
{
|
|
|
|
method: 'GET',
|
|
|
|
path: '/.well-known/public-keys',
|
|
|
|
handler: function (request, reply) {
|
|
|
|
// FOR DEV PURPOSES ONLY
|
|
|
|
reply(
|
|
|
|
{
|
|
|
|
keys: [
|
|
|
|
{
|
2014-09-04 00:51:55 +04:00
|
|
|
kid: "dev-1",
|
2014-09-04 00:57:18 +04:00
|
|
|
use: "sig",
|
2014-08-23 05:06:34 +04:00
|
|
|
kty: "RSA",
|
2014-08-28 22:19:08 +04:00
|
|
|
n: b64(bigint(serverPublicKey.n).toBuffer()),
|
2014-09-04 00:51:55 +04:00
|
|
|
e: b64(bigint(serverPublicKey.e).toBuffer())
|
2014-08-23 05:06:34 +04:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
},
|
2013-07-23 22:16:44 +04:00
|
|
|
{
|
|
|
|
method: 'GET',
|
2013-10-25 08:48:48 +04:00
|
|
|
path: '/.well-known/browserid/sign_in.html',
|
2014-02-01 07:36:25 +04:00
|
|
|
handler: {
|
|
|
|
file: './routes/static/sign_in.html'
|
2013-05-15 03:23:36 +04:00
|
|
|
}
|
2013-07-23 22:16:44 +04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
method: 'GET',
|
2013-10-25 08:48:48 +04:00
|
|
|
path: '/.well-known/browserid/provision.html',
|
2014-02-01 07:36:25 +04:00
|
|
|
handler: {
|
|
|
|
file: './routes/static/provision.html'
|
2013-05-25 02:58:08 +04:00
|
|
|
}
|
2013-08-20 02:00:28 +04:00
|
|
|
}
|
2013-07-23 22:16:44 +04:00
|
|
|
]
|
2013-05-25 02:58:08 +04:00
|
|
|
|
2013-07-23 22:16:44 +04:00
|
|
|
return routes
|
2013-07-04 01:46:22 +04:00
|
|
|
}
|