-
Notifications
You must be signed in to change notification settings - Fork 576
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: authorization refactor #387
Conversation
lib/client.js
Outdated
@@ -271,10 +272,15 @@ proto.createRequest = function createRequest(params) { | |||
} | |||
|
|||
var authResource = this._getResource(params); | |||
headers.authorization = this.authorization( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.authorization 是对外暴露的方法,需要进行同步。这个涉及对外 api 改动,参数为什么要变?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里还要重新设计下,对外暴露的方法基础上做封装
lib/common/signUtils.js
Outdated
* @param {Object} request | ||
* @param {String} expires | ||
*/ | ||
exports.buildRtmpCanonicalString = function buildRtmpCanonicalString(canonicalizedResource, request, expires) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个方法在哪里用到了?
lib/common/signUtils.js
Outdated
const crypto = require('crypto'); | ||
const is = require('is-type-of'); | ||
|
||
const SIGNED_PARAMETERS = ['acl', 'uploads', 'location', 'cors', 'logging', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
现在还没完全用const,保持和原有代码一致
git commit log,描述好改动原因 |
lib/common/signUtils.js
Outdated
@@ -0,0 +1,138 @@ | |||
'use strict'; | |||
|
|||
const crypto = require('crypto'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里都用var, es5 es6不要混用, 以下类似的都要改
lib/common/signUtils.js
Outdated
for (var key in headers) { | ||
var lowerKey = key.toLowerCase(); | ||
if (lowerKey === HEADER_CONTENT_TYPE | ||
||lowerKey === HEADER_CONTENT_MD5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code format ||lowerKey === HEADER_CONTENT_MD5 需要空格隔开
lib/common/signUtils.js
Outdated
for (var key in keys) { | ||
var paramKey = keys[key]; | ||
if (SIGNED_PARAMETERS.indexOf(paramKey) === -1) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code format 花括号位置
*/ | ||
exports.authorization = function authorization(accessKeyId, accessKeySecret, canonicalString) { | ||
return 'OSS ' + accessKeyId + ':' + this.computeSignature(accessKeySecret, canonicalString); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
空一行
lib/client.js
Outdated
@@ -271,10 +272,15 @@ proto.createRequest = function createRequest(params) { | |||
} | |||
|
|||
var authResource = this._getResource(params); | |||
headers.authorization = this.authorization( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里还要重新设计下,对外暴露的方法基础上做封装
Codecov Report
@@ Coverage Diff @@
## master #387 +/- ##
===========================================
- Coverage 96.56% 24.53% -72.04%
===========================================
Files 13 14 +1
Lines 1574 1598 +24
Branches 299 303 +4
===========================================
- Hits 1520 392 -1128
- Misses 54 1206 +1152
Continue to review full report at Codecov.
|
lib/common/signUtils.js
Outdated
for (var key in keys) { | ||
var paramKey = keys[key]; | ||
if (SIGNED_PARAMETERS.indexOf(paramKey) === -1) | ||
{ | ||
if (SIGNED_PARAMETERS.indexOf(paramKey) === -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里循环建议不使用continue, 新的eslint不建议使用,性能会提升, 将需要执行的代码放入if中
if (SIGNED_PARAMETERS.indexOf(paramKey) !== -1) {}
var canonicalizedResource = '' + resourcePath; | ||
var separatorString = '?'; | ||
|
||
if (is.string(parameters) && parameters.trim() !== '') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parameters 还要判断是否是数组 , 之前逻辑有可能传进来是数组, 参照之前的Object.keys只是遍历对象 而不能对数组进行遍历, 这里排序放到最后做,先把需要签名的字段取出放入临时数组
This reverts commit 36c271a.
* Revert "Create ISSUE_TEMPLATE.md" This reverts commit 53c024a. * Revert "chroe: build 4.14.1" This reverts commit 18f2f5e. * Revert "chore(release): 4.14.1" This reverts commit d3f6b13. * Revert "fix: signUtils header sort err fix (#418)" This reverts commit 60383ee. * Revert "chore: bump 4.14.0" This reverts commit a617866. * Revert "chore(release): 4.14.0" This reverts commit 4d3e7fe. * Revert "chore: remove the temp file" This reverts commit b9a2cec. * Revert "fix: _resumeMultipart not use yield" This reverts commit ba2382b. * Revert "fix(Browser): multipartUpload InvalidPartOrderError by doneParts repeat (#414)" This reverts commit 2b0967f. * Revert "feat: browser support blob (#409)" This reverts commit e8a78b5. * Revert "feat(browser): multipartUpload err will cancel this task (#399)" This reverts commit 64f8d68. * Revert "feat: signatureUrl refactor and support callback (#408)" This reverts commit 343938f. * Revert "chore: Delete example build file (#410)" This reverts commit 02b0efd. * Revert "feat: rm unused test data (#401)" This reverts commit 3d2ce4e. * Revert "feat: add ignore (#397)" This reverts commit 0f003aa. * Revert "refactor: add eslint for es6 (#382)" This reverts commit e3c1b54. * Revert "fix: issues #386 (#390)" This reverts commit 5b5ae3e. * Revert "refactor: authorization refactor (#387)" This reverts commit 59e245e. * Revert "feat: expose sdk version with OSS (#389)" This reverts commit 0bdc876.
refactor: authorization refactor