зеркало из https://github.com/mozilla/hawk.git
Merge pull request #109 from hendrikcech/getResponseHeader
client.authenticate in browser with browserify
This commit is contained in:
Коммит
866651fb3f
|
@ -154,11 +154,13 @@ hawk.client = {
|
|||
|
||||
options = options || {};
|
||||
|
||||
if (request.getResponseHeader('www-authenticate')) {
|
||||
var getResponseHeader = (request.getResponseHeader || request.getHeader).bind(request);
|
||||
|
||||
if (getResponseHeader('www-authenticate')) {
|
||||
|
||||
// Parse HTTP WWW-Authenticate header
|
||||
|
||||
var attributes = hawk.utils.parseAuthorizationHeader(request.getResponseHeader('www-authenticate'), ['ts', 'tsm', 'error']);
|
||||
var attributes = hawk.utils.parseAuthorizationHeader(getResponseHeader('www-authenticate'), ['ts', 'tsm', 'error']);
|
||||
if (!attributes) {
|
||||
return false;
|
||||
}
|
||||
|
@ -175,13 +177,13 @@ hawk.client = {
|
|||
|
||||
// Parse HTTP Server-Authorization header
|
||||
|
||||
if (!request.getResponseHeader('server-authorization') &&
|
||||
if (!getResponseHeader('server-authorization') &&
|
||||
!options.required) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
var attributes = hawk.utils.parseAuthorizationHeader(request.getResponseHeader('server-authorization'), ['mac', 'ext', 'hash']);
|
||||
var attributes = hawk.utils.parseAuthorizationHeader(getResponseHeader('server-authorization'), ['mac', 'ext', 'hash']);
|
||||
if (!attributes) {
|
||||
return false;
|
||||
}
|
||||
|
@ -212,7 +214,7 @@ hawk.client = {
|
|||
return false;
|
||||
}
|
||||
|
||||
var calculatedHash = hawk.crypto.calculatePayloadHash(options.payload, credentials.algorithm, request.getResponseHeader('content-type'));
|
||||
var calculatedHash = hawk.crypto.calculatePayloadHash(options.payload, credentials.algorithm, getResponseHeader('content-type'));
|
||||
return (calculatedHash === attributes.hash);
|
||||
},
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче