http-auth
Advanced tools
Comparing version 2.4.2 to 2.4.3
@@ -152,3 +152,3 @@ "use strict"; | ||
if (this.validateNonce(co.nonce)) { | ||
if (this.validateNonce(co.nonce, co.qop, co.nc)) { | ||
(function () { | ||
@@ -207,3 +207,3 @@ var ha2 = utils.md5(req.method + ':' + co.uri); | ||
key: 'validateNonce', | ||
value: function validateNonce(nonce) { | ||
value: function validateNonce(nonce, qop, nc) { | ||
var found = false; | ||
@@ -221,3 +221,10 @@ | ||
if (serverNonce[0] === nonce) { | ||
found = true; | ||
if (qop) { | ||
if (nc > serverNonce[2]) { | ||
found = true; | ||
++serverNonce[2]; | ||
} | ||
} else { | ||
found = true; | ||
} | ||
} | ||
@@ -241,3 +248,3 @@ } else { | ||
var nonce = utils.md5(_nodeUuid2.default.v4()); | ||
this.nonces.push([nonce, Date.now()]); | ||
this.nonces.push([nonce, Date.now(), 0]); | ||
@@ -244,0 +251,0 @@ return nonce; |
{ | ||
"name": "http-auth", | ||
"description": "Node.js package for HTTP basic and digest access authentication.", | ||
"version": "2.4.2", | ||
"version": "2.4.3", | ||
"author": "Gevorg Harutyunyan (http://github.com/gevorg)", | ||
@@ -6,0 +6,0 @@ "maintainers": [ |
@@ -92,2 +92,26 @@ # http-auth | ||
For [koa@next](https://github.com/koajs/koa/tree/v2.x) you can use [http-auth-koa](https://github.com/http-auth/http-auth-koa) | ||
```javascript | ||
// Authentication module. | ||
import auth from 'http-auth' | ||
import koaAuth from 'http-auth-koa' | ||
const basic = auth.basic({ | ||
realm: "Simon Area.", | ||
file: __dirname + "/../data/users.htpasswd" | ||
}); | ||
// Koa setup. | ||
import Koa from 'koa' | ||
const app = new Koa(); | ||
// Setup basic handler. | ||
app.use(async (ctx, next) => { | ||
await next(); | ||
ctx.body = `Welcome to koa ${ctx.req.user}!`; | ||
}); | ||
// Setup auth. | ||
app.use(koaAuth(basic)); | ||
``` | ||
## Protecting specific path | ||
@@ -94,0 +118,0 @@ ```javascript |
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
43810
17
792
264