使用DockerregistryAPI进行身份validation
我正在尝试使用DockerregistryAPI进行身份validation, url为https://registry-1.docker.io/v1/
我正在尝试打电话
https://registry-1.docker.io/v1/repositories/_/ubuntu/tags
不过我一直在回复如下:
401 { server: 'gunicorn/18.0', date: 'Sun, 01 Mar 2015 12:19:13 GMT', connection: 'close', expires: '-1', 'content-type': 'application/json', 'www-authenticate': 'Token', pragma: 'no-cache', 'cache-control': 'no-cache', 'content-length': '35', 'x-docker-registry-version': '0.8.2', 'x-docker-registry-config': 'prod', 'strict-transport-security': 'max-age=31536000' } {"error": "Requires authorization"}
我已经阅读了文档和论坛中的所有可用准则。
遵循这些指导方针,我首先对HUB进行授权并请求一个令牌。 这个成功,我从HUB获得令牌和cookie。 然后我提供所有这些registryAPI如下:
{ 'set-cookie': 'csrftoken=VfHe6...; Expires=Sun, 28 Feb 2016 12:19:13 GMT; Max-Age=31449600; Path=/; Secure', 'www-authenticate': 'Token signature=VfHe6...,repository="ubuntu",access=read', 'x-docker-token': 'Token signature=VfHe6...,repository="ubuntu",access=read', Authenticate: 'Token signature=VfHe6...,repository="ubuntu",access=read', Authorization: 'Token signature=VfHe6...,repository="ubuntu",access=read' }
您分享的文档中有这一行:
Token is only returned when the X-Docker-Token header is sent with request.
当您在集线器上进行身份validation时,您需要发送“X-Docker-Token:true”,然后在头部收到“X-Docker-Token”。 把它作为'Authorization:'发送到'X-Docker-Endpoints'的registry中,然后进入。
祝你好运! 🙂