openstack使用keystone实现权限管理和认证
在本系列里面主要分析一下keystone的主要功能,各种概念和使用过程
首先从登陆开始分析
1、输入用户名和密码登陆
2、封装好参数后,会根据keystone的wsgi url,把数据post过去
3、返回一个token和token id
这里把token的信息贴一下:
"token_data": {"access": {"token": {"issued_at": "2014-11-19T01:53:15.656497", "expires": "2014-11-19T02:53:15Z", "id": "002154355b7a4d8db9957efcd1b27418", "tenant": {"id": "bfe23127e2874fe5b19effcc1c22c55a", "enabled": true, "description": null, "name": "admin"}, "audit_ids": ["uL-f_gm3Q-uq640f_tXWww"]}, "serviceCatalog": [{"endpoints": [{"adminURL": "http://10.0.64.23:8774/v2/bfe23127e2874fe5b19effcc1c22c55a", "region": "RegionOne", "id": "2b557e9d23334812ab51f47176fb6a16", "internalURL": "http://10.0.64.23:8774/v2/bfe23127e2874fe5b19effcc1c22c55a", "publicURL": "http://10.0.64.23:8774/v2/bfe23127e2874fe5b19effcc1c22c55a"}], "endpoints_links": [], "type": "compute", "name": "nova"}, {"endpoints": [{"adminURL": "http://10.0.64.23:8004/v1/bfe23127e2874fe5b19effcc1c22c55a", "region": "RegionOne", "id": "3b84dd758fa644188061a685bcde18f6", "internalURL": "http://10.0.64.23:8004/v1/bfe23127e2874fe5b19effcc1c22c55a", "publicURL": "http://10.0.64.23:8004/v1/bfe23127e2874fe5b19effcc1c22c55a"}], "endpoints_links": [], "type": "orchestration", "name": "heat"}, {"endpoints": [{"adminURL": "http://10.0.64.23:8776/v2/bfe23127e2874fe5b19effcc1c22c55a", "region": "RegionOne", "id": "4d85e6ba59cf4b6b8fbaa292a084f8f3", "internalURL": "http://10.0.64.23:8776/v2/bfe23127e2874fe5b19effcc1c22c55a", "publicURL": "http://10.0.64.23:8776/v2/bfe23127e2874fe5b19effcc1c22c55a"}], "endpoints_links": [], "type": "volumev2", "name": "cinderv2"}, {"endpoints": [{"adminURL": "http://10.0.64.23:3333", "region": "RegionOne", "id": "4ec43d466e9845d4ad3eb71c67472d6c", "internalURL": "http://10.0.64.23:3333", "publicURL": "http://10.0.64.23:3333"}], "endpoints_links": [], "type": "s3", "name": "s3"}, {"endpoints": [{"adminURL": "http://10.0.64.23:9292", "region": "RegionOne", "id": "2ab8768792824b64a91ef485c154d083", "internalURL": "http://10.0.64.23:9292", "publicURL": "http://10.0.64.23:9292"}], "endpoints_links": [], "type": "image", "name": "glance"}, {"endpoints": [{"adminURL": "http://10.0.64.23:8000/v1", "region": "RegionOne", "id": "1a9fa5527e6144c4920c651ff1826dec", "internalURL": "http://10.0.64.23:8000/v1", "publicURL": "http://10.0.64.23:8000/v1"}], "endpoints_links": [], "type": "cloudformation", "name": "heat-cfn"}, {"endpoints": [{"adminURL": "http://10.0.64.23:8776/v1/bfe23127e2874fe5b19effcc1c22c55a", "region": "RegionOne", "id": "a7b3b998651847b6abc69820cd5c09f2", "internalURL": "http://10.0.64.23:8776/v1/bfe23127e2874fe5b19effcc1c22c55a", "publicURL": "http://10.0.64.23:8776/v1/bfe23127e2874fe5b19effcc1c22c55a"}], "endpoints_links": [], "type": "volume", "name": "cinder"}, {"endpoints": [{"adminURL": "http://10.0.64.23:9898/bfe23127e2874fe5b19effcc1c22c55a", "region": "RegionOne", "id": "99ed5bd336964b03851dabfe1204d34c", "internalURL": "http://10.0.64.23:9898/bfe23127e2874fe5b19effcc1c22c55a", "publicURL": "http://10.0.64.23:9898/bfe23127e2874fe5b19effcc1c22c55a"}], "endpoints_links": [], "type": "traffic", "name": "traffic"}, {"endpoints": [{"adminURL": "http://10.0.64.23:8773/services/Admin", "region": "RegionOne", "id": "ac47405802004cc1ab3182e727ea2eea", "internalURL": "http://10.0.64.23:8773/services/Cloud", "publicURL": "http://10.0.64.23:8773/services/Cloud"}], "endpoints_links": [], "type": "ec2", "name": "ec2"}, {"endpoints": [{"adminURL": "http://10.0.64.23:8774/v2.1/bfe23127e2874fe5b19effcc1c22c55a", "region": "RegionOne", "id": "297edb113d724ec698cac5495b339e39", "internalURL": "http://10.0.64.23:8774/v2.1/bfe23127e2874fe5b19effcc1c22c55a", "publicURL": "http://10.0.64.23:8774/v2.1/bfe23127e2874fe5b19effcc1c22c55a"}], "endpoints_links": [], "type": "computev21", "name": "novav21"}, {"endpoints": [{"adminURL": "http://10.0.64.23:35357/v2.0", "region": "RegionOne", "id": "0d15b969b59b4e97b2c37f599368a4a9", "internalURL": "http://10.0.64.23:5000/v2.0", "publicURL": "http://10.0.64.23:5000/v2.0"}], "endpoints_links": [], "type": "identity", "name": "keystone"}], "user": {"username": "admin", "roles_links": [], "id": "3032ec3f3dac45faaf36e9b8b2b413fb", "roles": [{"name": "heat_stack_owner"}, {"name": "admin"}, {"name": "_member_"}], "name": "admin"}, "metadata": {"is_admin": 0, "roles": ["ef0b4e4175e04b2a9156eb33f7cef09e", "2dc05a62b13d4233970fd5cc08c75059", "9fe2ff9ee4384b1894a90878d3e92bab"]}}}, "user": {"username": "admin", "name": "admin", "enabled": true, "id": "3032ec3f3dac45faaf36e9b8b2b413fb", "tenantId": "bfe23127e2874fe5b19effcc1c22c55a", "email": null}, "key": "002154355b7a4d8db9957efcd1b27418", "token_version": "v2.0", "tenant": {"id": "bfe23127e2874fe5b19effcc1c22c55a", "enabled": true, "description": null, "name": "admin"}, "metadata": {"roles": ["ef0b4e4175e04b2a9156eb33f7cef09e", "2dc05a62b13d4233970fd5cc08c75059", "9fe2ff9ee4384b1894a90878d3e92bab"]}} | 1 | NULL | 3032ec3f3dac45faaf36e9b8b2b413fb |
| 002b175e7b1b4732aaaabc55a3dbc0e5 | 2014-11-18 03:33:08 | {"bind": null, "token_data": {"access": {"token": {"issued_at": "2014-11-18T02:33:08.668386", "expires": "2014-11-18T03:33:08Z", "id": "002b175e7b1b4732aaaabc55a3dbc0e5", "tenant": {"id": "bfe23127e2874fe5b19effcc1c22c55a", "enabled": true, "description": null, "name": "admin"}, "audit_ids": ["3gxYQq20RZKA00iHEwnJSA"]}, "serviceCatalog": [{"endpoints": [{"adminURL": "http://10.0.64.23:8774/v2/bfe23127e2874fe5b19effcc1c22c55a", "region": "RegionOne", "id": "2b557e9d23334812ab51f47176fb6a16", "internalURL": "http://10.0.64.23:8774/v2/bfe23127e2874fe5b19effcc1c22c55a", "publicURL": "http://10.0.64.23:8774/v2/bfe23127e2874fe5b19effcc1c22c55a"}], "endpoints_links": [], "type": "compute", "name": "nova"}, {"endpoints": [{"adminURL": "http://10.0.64.23:8004/v1/bfe23127e2874fe5b19effcc1c22c55a", "region": "RegionOne", "id": "3b84dd758fa644188061a685bcde18f6", "internalURL": "http://10.0.64.23:8004/v1/bfe23127e2874fe5b19effcc1c22c55a", "publicURL": "http://10.0.64.23:8004/v1/bfe23127e2874fe5b19effcc1c22c55a"}], "endpoints_links": [], "type": "orchestration", "name": "heat"}, {"endpoints": [{"adminURL": "http://10.0.64.23:8776/v2/bfe23127e2874fe5b19effcc1c22c55a", "region": "RegionOne", "id": "4d85e6ba59cf4b6b8fbaa292a084f8f3", "internalURL": "http://10.0.64.23:8776/v2/bfe23127e2874fe5b19effcc1c22c55a", "publicURL": "http://10.0.64.23:8776/v2/bfe23127e2874fe5b19effcc1c22c55a"}], "endpoints_links": [], "type": "volumev2", "name": "cinderv2"}, {"endpoints": [{"adminURL": "http://10.0.64.23:3333", "region": "RegionOne", "id": "4ec43d466e9845d4ad3eb71c67472d6c", "internalURL": "http://10.0.64.23:3333", "publicURL": "http://10.0.64.23:3333"}], "endpoints_links": [], "type": "s3", "name": "s3"}, {"endpoints": [{"adminURL": "http://10.0.64.23:9292", "region": "RegionOne", "id": "2ab8768792824b64a91ef485c154d083", "internalURL": "http://10.0.64.23:9292", "publicURL": "http://10.0.64.23:9292"}], "endpoints_links": [], "type": "image", "name": "glance"}, {"endpoints": [{"adminURL": "http://10.0.64.23:8000/v1", "region": "RegionOne", "id": "1a9fa5527e6144c4920c651ff1826dec", "internalURL": "http://10.0.64.23:8000/v1", "publicURL": "http://10.0.64.23:8000/v1"}], "endpoints_links": [], "type": "cloudformation", "name": "heat-cfn"}, {"endpoints": [{"adminURL": "http://10.0.64.23:8776/v1/bfe23127e2874fe5b19effcc1c22c55a", "region": "RegionOne", "id": "a7b3b998651847b6abc69820cd5c09f2", "internalURL": "http://10.0.64.23:8776/v1/bfe23127e2874fe5b19effcc1c22c55a", "publicURL": "http://10.0.64.23:8776/v1/bfe23127e2874fe5b19effcc1c22c55a"}], "endpoints_links": [], "type": "volume", "name": "cinder"}, {"endpoints": [{"adminURL": "http://10.0.64.23:9898/bfe23127e2874fe5b19effcc1c22c55a", "region": "RegionOne", "id": "99ed5bd336964b03851dabfe1204d34c", "internalURL": "http://10.0.64.23:9898/bfe23127e2874fe5b19effcc1c22c55a", "publicURL": "http://10.0.64.23:9898/bfe23127e2874fe5b19effcc1c22c55a"}], "endpoints_links": [], "type": "traffic", "name": "traffic"}, {"endpoints": [{"adminURL": "http://10.0.64.23:8773/services/Admin", "region": "RegionOne", "id": "ac47405802004cc1ab3182e727ea2eea", "internalURL": "http://10.0.64.23:8773/services/Cloud", "publicURL": "http://10.0.64.23:8773/services/Cloud"}], "endpoints_links": [], "type": "ec2", "name": "ec2"}, {"endpoints": [{"adminURL": "http://10.0.64.23:8774/v2.1/bfe23127e2874fe5b19effcc1c22c55a", "region": "RegionOne", "id": "297edb113d724ec698cac5495b339e39", "internalURL": "http://10.0.64.23:8774/v2.1/bfe23127e2874fe5b19effcc1c22c55a", "publicURL": "http://10.0.64.23:8774/v2.1/bfe23127e2874fe5b19effcc1c22c55a"}], "endpoints_links": [], "type": "computev21", "name": "novav21"}, {"endpoints": [{"adminURL": "http://10.0.64.23:35357/v2.0", "region": "RegionOne", "id": "0d15b969b59b4e97b2c37f599368a4a9", "internalURL": "http://10.0.64.23:5000/v2.0", "publicURL": "http://10.0.64.23:5000/v2.0"}], "endpoints_links": [], "type": "identity", "name": "keystone"}], "user": {"username": "admin", "roles_links": [], "id": "3032ec3f3dac45faaf36e9b8b2b413fb", "roles": [{"name": "heat_stack_owner"}, {"name": "admin"}, {"name": "_member_"}], "name": "admin"}, "metadata": {"is_admin": 0, "roles": ["ef0b4e4175e04b2a9156eb33f7cef09e", "2dc05a62b13d4233970fd5cc08c75059", "9fe2ff9ee4384b1894a90878d3e92bab"]}}}, "user": {"username": "admin", "name": "admin", "enabled": true, "id": "3032ec3f3dac45faaf36e9b8b2b413fb", "tenantId": "bfe23127e2874fe5b19effcc1c22c55a", "email": null}, "key": "002b175e7b1b4732aaaabc55a3dbc0e5", "token_version": "v2.0", "tenant": {"id": "bfe23127e2874fe5b19effcc1c22c55a", "enabled": true, "description": null, "name": "admin"}, "metadata": {"roles": ["ef0b4e4175e04b2a9156eb33f7cef09e", "2dc05a62b13d4233970fd5cc08c75059", "9fe2ff9ee4384b1894a90878d3e92bab"]}}
里面有tenant信息 role信息,登陆成功后request中会有此token,所以每次权限验证的时候都拿这个token就可以了,其实就跟以前的session没什么区别