|
@@ -24,26 +24,19 @@ export const AES = content => {
|
|
|
*/
|
|
|
export const getAuthorization = (infos, type) => {
|
|
|
// {type} {invoker}:base64(sha1(method&uri×tamp&{secret}))
|
|
|
- const timestamp = Date.now();
|
|
|
if (type === "secret") {
|
|
|
// accessKey | method&uri×tamp&accessSecret
|
|
|
- const str = `${infos.method.toLowerCase()}&${infos.uri}&${timestamp}&${
|
|
|
- infos.accessSecret
|
|
|
- }`;
|
|
|
+ const str = `${infos.method.toLowerCase()}&${infos.uri}&${
|
|
|
+ infos.timestamp
|
|
|
+ }&${infos.accessSecret}`;
|
|
|
const sign = CryptoJS.enc.Base64.stringify(CryptoJS.SHA1(str));
|
|
|
- return {
|
|
|
- timestamp,
|
|
|
- Authorization: `Secret ${infos.accessKey}:${sign}`
|
|
|
- };
|
|
|
+ return `Secret ${infos.accessKey}:${sign}`;
|
|
|
} else if (type === "token") {
|
|
|
// userId | method&uri×tamp&token
|
|
|
- const str = `${infos.method.toLowerCase()}&${infos.uri}&${timestamp}&${
|
|
|
- infos.token
|
|
|
- }`;
|
|
|
+ const str = `${infos.method.toLowerCase()}&${infos.uri}&${
|
|
|
+ infos.timestamp
|
|
|
+ }&${infos.token}`;
|
|
|
const sign = CryptoJS.enc.Base64.stringify(CryptoJS.SHA1(str));
|
|
|
- return {
|
|
|
- timestamp,
|
|
|
- Authorization: `Token ${infos.account}:${sign}`
|
|
|
- };
|
|
|
+ return `Token ${infos.account}:${sign}`;
|
|
|
}
|
|
|
};
|