Don't apply /v1 prefix to .well-known or related files.

This commit is contained in:
Ryan Kelly 2013-10-23 10:49:29 +11:00
Родитель 78c8ba1099
Коммит 40d557a368
3 изменённых файлов: 41 добавлений и 27 удалений

Просмотреть файл

@ -39,30 +39,6 @@ module.exports = function (log, crypto, error, isA, serverPublicKey, bridge) {
file: './provision.html'
}
}
},
{
method: 'POST',
path: '/get_random_bytes',
config: {
handler: function getRandomBytes(request) {
request.reply({ data: crypto.randomBytes(32).toString('hex') })
}
}
},
{
method: 'GET',
path: '/verify_email',
config: {
handler: function (request, next) {
return request.reply.redirect(bridge.url + request.raw.req.url)
},
validate: {
query: {
code: isA.String().regex(HEX_STRING).required(),
uid: isA.String().max(64).required()
}
}
}
}
]

Просмотреть файл

@ -24,20 +24,21 @@ module.exports = function (
var password = require('./password')(log, isA, error, models.Account, models.tokens)
var session = require('./session')(log, isA, error, models.Account, models.tokens)
var sign = require('./sign')(log, isA, error, signer, models.Account)
var util = require('./util')(log, crypto, error, isA, serverPublicKey, config.bridge)
var v1Routes = [].concat(
auth,
idp,
account,
password,
session,
sign
sign,
util
)
v1Routes.forEach(function(route) {
route.path = "/v1" + route.path
})
var routes = defaults.concat(v1Routes)
var routes = defaults.concat(idp, v1Routes)
return routes
}

37
routes/util.js Normal file
Просмотреть файл

@ -0,0 +1,37 @@
/* 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/. */
module.exports = function (log, crypto, error, isA, serverPublicKey, bridge) {
const HEX_STRING = /^(?:[a-fA-F0-9]{2})+$/
var routes = [
{
method: 'POST',
path: '/get_random_bytes',
config: {
handler: function getRandomBytes(request) {
request.reply({ data: crypto.randomBytes(32).toString('hex') })
}
}
},
{
method: 'GET',
path: '/verify_email',
config: {
handler: function (request, next) {
return request.reply.redirect(bridge.url + request.raw.req.url)
},
validate: {
query: {
code: isA.String().regex(HEX_STRING).required(),
uid: isA.String().max(64).required()
}
}
}
}
]
return routes
}