认证鉴权

签名认证

签名计算方法

Authorization: UPYUN <Operator>:<Signature>

<Signature> = Base64 (HMAC-SHA1 (<Password>,
<Method>&
<URI>&
<Date>&
<Content-MD5>
))

相关参数说明:

参数 必选 说明
Operator 服务的操作员名称
Method 请求方式,如:GET、POST、PUT、HEAD 等
URI 请求路径
Date 请求日期时间,GMT 格式字符串 (RFC 1123),如 Wed, 29 Oct 2014 02:26:58 GMT
Content-MD5 请求体的 MD5 校验值,如果请求体为空,可以为空
Password 服务的操作员密码的 MD5 值

举例

参数信息:

// 操作员信息
Operator = operator123          
Password = MD5(password123) = 482c811da5d5b4bc6d497ffa98491e38

// 参数
Method = POST                           
URI = /pretreatment/
Date = Wed, 09 Nov 2016 14:26:58 GMT
Content-MD5 = MD5(service=upyun-temp&notify_url=/upyun_notify_url&source=/tmp.mp4&tasks=W3siYXZvcHRzIjoiL3MvMjQwcCg0OjMpL2FzLzEvci8zMCIsInJldHVybl9pbmZvIjp0cnVlLCJzYXZlX2FzIjoiL2EvYi5tcDQiLCJ0eXBlIjoidmlkZW8ifSx7ImF2b3B0cyI6Ii9pL0wyRXZZaTlqTG0xd05BPT0vaS9MekV2TWk4ekxtMXdOQT09Iiwic2F2ZV9hcyI6Ii9jb25jYXQvYS5tcDQiLCJ0eXBlIjoidmNvbmNhdCJ9XQ==&accept=json)
            = a2d75510f7ec654cc24cfa2b5a5a8182

生成 Signature:

Signature = Base64 (HMAC-SHA1 (<Password>,
<Method>&
<URI>&
<Date>&
<Content-MD5>
))
// 内容拼接时,不用换行或空格,上面格式的换行或空格是为了方便阅读
= Base64 (HMAC-SHA1 (482c811da5d5b4bc6d497ffa98491e38,POST&/pretreatment/&Wed, 09 Nov 2016 14:26:58 GMT&a2d75510f7ec654cc24cfa2b5a5a8182))
// HMAC-SHA1 返回的原生二进制数据进行 Base64 编码
= 6KGqGX4tFwqnCdSndEmGQsR1jQU=

Authorization 签名:

Authorization: UPYUN upyun:6KGqGX4tFwqnCdSndEmGQsR1jQU=

完整的请求:

POST /pretreatment/ HTTP/1.1
Authorization: UPYUN upyun:6KGqGX4tFwqnCdSndEmGQsR1jQU=
Content-MD5: a2d75510f7ec654cc24cfa2b5a5a8182
Date: Wed, 9 Nov 2016 14:26:58 GMT
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Host: p0.api.upyun.com
Content-Length: 668

service=upyun-temp&notify_url=/upyun_notify_url&source=/tmp.mp4&tasks=W3siYXZvcHRzIjoiL3MvMjQwcCg0OjMpL2FzLzEvci8zMCIsInJldHVybl9pbmZvIjp0cnVlLCJzYXZlX2FzIjoiL2EvYi5tcDQiLCJ0eXBlIjoidmlkZW8ifSx7ImF2b3B0cyI6Ii9pL0wyRXZZaTlqTG0xd05BPT0vaS9MekV2TWk4ekxtMXdOQT09Iiwic2F2ZV9hcyI6Ii9jb25jYXQvYS5tcDQiLCJ0eXBlIjoidmNvbmNhdCJ9XQ==&accept=json

如有疑问请 联系我们