can*_*an. 6 identity token openstack
我遵循了这个指南:http://keystone.openstack.org/api_curl_examples.html
似乎我通过运行得到了一个有效的令牌:
curl -d '{"auth":{"passwordCredentials":{"username": "can", "password": "mypassword"}}}' -H "Content-type: application/json" http://url:35357/v2.0/tokens
Run Code Online (Sandbox Code Playgroud)
它返回了:
{
"access":
{
"token":
{
"expires": "2012-05-21T14:35:17Z",
"id": "468da447bd1c4821bbc5def0498fd441"
},
"serviceCatalog": {},
"user":
{
"username": "can",
"roles_links": [],
"id": "bb6d3a09ad0c4924bf20c1a32ccb5781",
"roles": [],
"name": "can"
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我来到接下来的几节来验证这个令牌时,我遇到了这个神奇的数字:X-Auth-Token:999888777666.起初我以为这是我得到的令牌,但我错了.
我想我可能错过了一些东西,所以我阅读了openstack文档中的相关章节(http://keystone.openstack.org/configuration.html和http://docs.openstack.org/api/openstack-compute/programmer/content /),但仍然不知道数字是如何来的.
任何人都可以向我解释
真正的数字(字符串确实)是keystone.conf文件中的admin_token设置.在keystone.conf中的[DEFAULT]部分下设置
admin_token = abcd1234
Run Code Online (Sandbox Code Playgroud)
如果您不将它用于管理操作,您会看到类似的内容
ubuntu@i-000004bc:~/devstack$ curl http://localhost:35357/v2.0/tenants
{"error": {"message": "The request you have made requires authentication.", "code": 401, "title": "Not Authorized"}}
Run Code Online (Sandbox Code Playgroud)
如果你使用它,你会看到类似的东西
ubuntu@i-000004bc:~/devstack$ curl -H "X-Auth-Token: abcd1234" http://localhost:35357/v2.0/tenants
{"tenants_links": [], "tenants": [{"enabled": true, "description": null, "name": "demo", "id": "aee8a46babcb4e4286021c8f6ef996cd"}, {"enabled": true, "description": null, "name": "invisible_to_admin", "id": "de17fea45de148ada0a58e998e6c3e73"}, {"enabled": true, "description": null, "name": "admin", "id": "f34b0c8ab30e450489b121fbe723fde5"}, {"enabled": true, "description": null, "name": "service", "id": "fbe3e2e530fd47298cb2cba1b4afa3da"}]}
Run Code Online (Sandbox Code Playgroud)
令牌本身位于dict["access"]["token"]["id"]后续 HTTP 请求标头中的部分,即
X-Auth-Token: 468da447bd1c4821bbc5def0498fd441
Run Code Online (Sandbox Code Playgroud)
值 999888777666 来自curl示例教程,肯定不起作用。
至于令牌本身的值,它是由 OpenStack 服务随机生成的,从您的角度来看,它不应该包含任何有用的信息。
(顺便说一句,您可能不应该将令牌粘贴到论坛中,因为它们的有效期为 24 小时,任何拥有令牌副本并访问您的计算端点的人都可以使用它来冒充您)。
| 归档时间: |
|
| 查看次数: |
24830 次 |
| 最近记录: |