Comparing version 0.4.2-r5 to 0.4.3
@@ -59,2 +59,16 @@ /** | ||
/** | ||
* Contains the authorization informations. | ||
* | ||
* { | ||
* user: The name of the authentificating user. | ||
* pass: The password. | ||
* type: The authorization type, e.g. basic | ||
* } | ||
* | ||
* @var {Object} | ||
* @protected | ||
*/ | ||
this._auth = null; | ||
if (req.url) { | ||
@@ -101,2 +115,13 @@ var tmp = url.parse(req.url, true); | ||
if (req.headers.authorization) { | ||
var tmp = req.headers.authorization.split(" "); | ||
if (tmp[0] == 'Basic') { | ||
this._auth = {type: tmp[0]}; | ||
var tmp = new Buffer(tmp[1], 'base64').toString().split(':'); | ||
this._auth.user = tmp[0]; | ||
this._auth.pass = tmp[1]; | ||
} | ||
// TODO: Digest | ||
} | ||
/** | ||
@@ -231,4 +256,18 @@ * Contains the request method (GET, POST ...) | ||
/** | ||
* The authorization informations. | ||
* | ||
* user, pass, type | ||
* | ||
* @member {Object} path | ||
* @readonly | ||
*/ | ||
nepp.createGS(module.exports.prototype, 'auth', | ||
function getAuth() { | ||
return this._auth; | ||
} | ||
); | ||
// }}} | ||
nepp(module.exports.prototype); |
@@ -154,9 +154,18 @@ /** | ||
* @param {http.ServerResponse} resp Reponse Object. | ||
* @param {String} realm The realm. | ||
* @param {String} type The auth type. Defaults to basic. | ||
* @param {String} language The language of the content. | ||
*/ | ||
module.exports.prototype.writeUnauthorized = function(resp, language) { | ||
module.exports.prototype.writeUnauthorized = function(resp, realm, type, language) { | ||
VC.instance_of(resp, 'resp', http.ServerResponse); | ||
if (type) | ||
type = VC.string(type, 'type', 1); | ||
else | ||
type = 'Basic'; | ||
VC.string(realm, 'realm', 1); | ||
var header = this._createHeader(language); | ||
header['WWW-Authenticate'] = type + ' realm="' + realm + '"'; | ||
resp.writeHead( | ||
HTTPStatusCodes.UNAUTHORIZED, | ||
this._createHeader(language) | ||
header | ||
); | ||
@@ -211,2 +220,3 @@ resp.end(this._prepareErrorMessage('Authorization Required')); | ||
/** | ||
@@ -213,0 +223,0 @@ * The charset that will be used for all responses. |
{ | ||
"name": "mvcfun", | ||
"version": "0.4.2r5", | ||
"version": "0.4.3", | ||
"description": "MVC based web server framework", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
166478
4691
25