Skip to content
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

Merged
merged 8 commits into from
Mar 21, 2018
Merged

refactor: authorization refactor #387

merged 8 commits into from
Mar 21, 2018

Conversation

duan007a
Copy link
Contributor

refactor: authorization refactor

lib/client.js Outdated
@@ -271,10 +272,15 @@ proto.createRequest = function createRequest(params) {
}

var authResource = this._getResource(params);
headers.authorization = this.authorization(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.authorization 是对外暴露的方法,需要进行同步。这个涉及对外 api 改动,参数为什么要变?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里还要重新设计下,对外暴露的方法基础上做封装

* @param {Object} request
* @param {String} expires
*/
exports.buildRtmpCanonicalString = function buildRtmpCanonicalString(canonicalizedResource, request, expires) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个方法在哪里用到了?

const crypto = require('crypto');
const is = require('is-type-of');

const SIGNED_PARAMETERS = ['acl', 'uploads', 'location', 'cors', 'logging',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

现在还没完全用const,保持和原有代码一致

@PeterRao
Copy link
Collaborator

git commit log,描述好改动原因

@@ -0,0 +1,138 @@
'use strict';

const crypto = require('crypto');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里都用var, es5 es6不要混用, 以下类似的都要改

for (var key in headers) {
var lowerKey = key.toLowerCase();
if (lowerKey === HEADER_CONTENT_TYPE
||lowerKey === HEADER_CONTENT_MD5
Copy link
Contributor

@binghaiwang binghaiwang Mar 15, 2018

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 需要空格隔开

for (var key in keys) {
var paramKey = keys[key];
if (SIGNED_PARAMETERS.indexOf(paramKey) === -1)
{
Copy link
Contributor

@binghaiwang binghaiwang Mar 15, 2018

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);
};
Copy link
Contributor

@binghaiwang binghaiwang Mar 15, 2018

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(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里还要重新设计下,对外暴露的方法基础上做封装

@codecov-io
Copy link

codecov-io commented Mar 19, 2018

Codecov Report

Merging #387 into master will decrease coverage by 72.03%.
The diff coverage is 12.28%.

Impacted file tree graph

@@             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
Impacted Files Coverage Δ
lib/common/signUtils.js 11.32% <11.32%> (ø)
lib/client.js 52.63% <25%> (-40.76%) ⬇️
lib/common/callback.js 6.25% <0%> (-93.75%) ⬇️
lib/common/multipart-copy.js 7.92% <0%> (-91.09%) ⬇️
lib/common/multipart.js 10.71% <0%> (-88.1%) ⬇️
lib/bucket.js 12.28% <0%> (-85.97%) ⬇️
lib/object.js 12.76% <0%> (-84.05%) ⬇️
lib/managed_upload.js 13.98% <0%> (-82.52%) ⬇️
lib/rtmp.js 14.01% <0%> (-76.64%) ⬇️
lib/cluster.js 23.07% <0%> (-76.16%) ⬇️
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 02fef3f...a7732a3. Read the comment docs.

for (var key in keys) {
var paramKey = keys[key];
if (SIGNED_PARAMETERS.indexOf(paramKey) === -1)
{
if (SIGNED_PARAMETERS.indexOf(paramKey) === -1) {
Copy link
Contributor

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() !== '') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parameters 还要判断是否是数组 , 之前逻辑有可能传进来是数组, 参照之前的Object.keys只是遍历对象 而不能对数组进行遍历, 这里排序放到最后做,先把需要签名的字段取出放入临时数组

@PeterRao PeterRao merged commit 59e245e into ali-sdk:master Mar 21, 2018
popomore added a commit that referenced this pull request Apr 3, 2018
popomore added a commit that referenced this pull request Apr 3, 2018
* 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.
@duan007a duan007a deleted the refactor/authorization branch April 12, 2018 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants