Baidu AI Cloud
中国站

百度智能云

CDN

Set the Access Authorization

Interface

This interface is used to set the access authentication of the domain name.

Method Path Description
PUT /v2/domain/{domain}/config?requestAuth Configure access authentication

domain: Modify the configured CDN acceleration domain name.

Request body

Parameter Optional Type Description
requestAuth Required requestAuth Access authorization configuration

requestAuth type

Parameter Optional Type Description
type Required String Three authentication methods of A/B/C
key1 Required String For the main authorization key, enter uppercase and lowercase letters, figures, with a length of 6 to 32 bits
key2 Optional String For the secondary authorization key, enter uppercase and lowercase letters and numbers, with a length of 6 to 32 bits
timeout Optional Int The authorization cache time supports mode B or mode C to set the parameter, in second; the expiration time for URL authorization refers to “timestamp+timeout”; it defaults to be 1,800. UTC time
whiteList Optional List Whitelist, authentication is not required for file names in this list.
signArg Optional String The signed parameter name, only effect on typeC
timeArg Optional String The time stamp parameter name is only valid to typeC
timestampMetric Optional string Time format。 The value is 10, 16 or yyyyMMDDhhmm, respectively indicating the decimal time format, hexadecimal time format and string time format. As for yyyyMMDDhhmm, the value can only be realized when type is B

Note When the request body is { "requestAuth ":[]}, the authentication feature is disabled. For case, see request example 4.

Response code (Http Status Code)

HTTP Status Code Description
200 Success
400 Update failures, parameter errors, etc.

Request example1

PUT /v2/domain/myself.baidu.com/config?requestAuth HTTP/1.1 
Host: cdn.baidubce.com 
Content-Length: 18
Content-Type: text/json;utf-8

{ 
    "requestAuth": { 
        "type": "c", 
        "key1": "secretekey1",
        "key2": "secretekey2",
        "timeout": 300, 
        "whiteList": ["/crossdomain.xml"], 
        "signArg":"sign",         
        "timeArg":"t"     
        
    } 
} 

Request example 2

PUT /v2/domain/myself.baidu.com/config?requestAuth HTTP/1.1 
Host: cdn.baidubce.com 
Content-Length: 18
Content-Type: text/json;utf-8

{ 
    "requestAuth": { 
        "type": "B", 
        "key1": "JFSDKFJLS", 
        "key2": "JLFS2fjkd", 
        "delAuthKey": true, 
        "timeout": 1800, 
        "timestampMetric": "yyyyMMDDhhmm" 
    } 
} 

Request example3

PUT /v2/domain/myself.baidu.com/config?requestAuth HTTP/1.1 
Host: cdn.baidubce.com 
Content-Length: 18
Content-Type: text/json;utf-8

{ 
    "requestAuth": { 
        "type": "A", 
        "key1": "JFSDKFJLS", 
        "key2": "JLFS2fjkd", 
        "delAuthKey": true, 
        "timeout": 1800, 
        "timestampMetric": 10 
    } 
} 

Request example 4

PUT /v2/domain/myself.baidu.com/config?requestAuth HTTP/1.1 
Host: cdn.baidubce.com 
Content-Length: 18
Content-Type: text/json;utf-8

{"requestAuth":[]} 

Response example

HTTP/1.1 200 OK 
Server: nginx 
Date: Wed, 26 Jun 2019 05:57:29 GMT 
Content-Type: application/json; charset=utf-8 
Transfer-Encoding: chunked 
Connection: keep-alive 
X-Powered-By: PHP/7.1.5 
x-bce-request-id: 8a9c4d38-5198-ed4e-b279-272fdde46e4b

{"status":"RUNNING"} 
Previous
Query the Access ua Control
Next
Set Cors Cross-domain