OpenStack Identity(Keystone)概述及示例

OpenStack 的验证服务有两个主要功能:

  1. 用户管理(租户、用户、权限)

  2. Service catalog,管理服务的目录和它们的endpoint。

 

相关概念

1. User

  User即用户,他们代表访问openstack的人或程序。Users通过认证信息(credentials,如密码、API Keys等)进行验证。

2. Tenant

  Tenant即租户,它是各个服务中的一些可以访问的资源集合。在Swift,资源是以tenant为单位进行划分的。Users默认的总是绑定到某些tenant上。

3. Role

  Role即角色,Roles代表一组用户可以访问的资源权限。Role是在验证服务定义,但是具体意义由执行操作的服务(比如 swift)解释。

4. Service

  Service即服务,如Nova、Glance、Swift。根据前三个概念(User,Tenant和Role)一个服务可以确认当前用户是否具有访问其资源的权限。但是当一个user尝试着访问其租户内的service时,他必须知道这个service是否存在以及如何访问这个service,这里通常使用一些不同的名称表示不同的服务。在上文中谈到的Role,实际上也是可以绑定到某个service的。例如,当swift需要一个管理员权限的访问进行对象创建时,对于相同的role我们并不一定也需要对nova进行管理员权限的访问。为了实现这个目标,我们应该创建两个独立的管理员role,一个绑定到swift,另一个绑定到nova,从而实现对swift进行管理员权限访问不会影响到Nova或其他服务。 

5. Endpoint

  Endpoint,翻译为“端点”,我们可以理解它是一个服务暴露出来的访问点,如果需要访问一个服务,则必须知道他的endpoint。因此,在keystone中包含一个endpoint模板(endpoint template,在安装keystone的时候我们可以在conf文件夹下看到这个文件),这个模板提供了所有存在的服务endpoints信息。一个endpoint template包含一个URLs列表,列表中的每个URL都对应一个服务实例的访问地址,并且具有public、private和admin这三种权限。public url可以被全局访问,private url只能被局域网访问,admin url被从常规的访问中分离。

6、Token

  Token是访问资源的钥匙。它是通过Keystone验证后的返回值,在之后的与其他服务交互中只需要携带Token值即可。每个Token都有一个有效期,Token只在有效期内是有效的。

 

主要关系

1、租户下,管理着一堆用户(人,或程序)。

2、每个用户都有自己的credentials(凭证)。用户名+密码,或者,用户名+API key,或其他凭证。

3、用户在访问其他资源(计算、存储)之前,需要用自己的credential,去请求keystone服务,获得验证信息(主要是Token信息)和服务信息(服务目录和它们的endpoint)。

4、用户拿着Token信息,就可以去访问特点的资源了。

 

示例

向keystone发送请求:

1 > POST http://192.168.150.129:35357/v2.0/tokens
1 > Accept: application/json
1 > Content-Type: application/json

{
     "auth":{
        "tenantName":"service",
        "passwordCredentials":{
            "username":"swift",
            "password":"password"
        }
    }
}

 

keystone的响应

2 < 200
2 < Vary: X-Auth-Token
2 < Date: Tue, 30 Jul 2013 08:44:30 GMT
2 < Content-Length: 3354
2 < Content-Type: application/json
2 < Connection: keep-alive

 {
    "access": {
        "token": {
            "issued_at": "2013-07-30T08:44:28.336139",
             "expires": "2013-07-31T08:44:28Z",
             "id": "MIIGXgYJKoZIhvcNAQcCoIIGTzCCBksCAQExCTAHBgUrDgMCGjCCBLQGCSqGSIb3DQEHAaCCBKUEggSheyJhY2Nlc3MiOiB7InRva2VuIjogeyJpc3N1ZWRfYXQiOiAiMjAxMy0wNy0zMFQwODo0NDoyOC4zMzYxMzkiLCAiZXhwaXJlcyI6ICIyMDEzLTA3LTMxVDA4OjQ0OjI4WiIsICJpZCI6ICJwbGFjZWhvbGRlciIsICJ0ZW5hbnQiOiB7ImRlc2NyaXB0aW9uIjogbnVsbCwgImVuYWJsZWQiOiB0cnVlLCAiaWQiOiAiOGMwMDhkNjhiYmQ3NGNkODhkZDA0YTRiMzc3MjU0ZTciLCAibmFtZSI6ICJzZXJ2aWNlIn19LCAic2VydmljZUNhdGFsb2ciOiBbeyJlbmRwb2ludHMiOiBbeyJhZG1pblVSTCI6ICJodHRwOi8vMTkyLjE2OC4xNTAuMTI5OjgwODAiLCAicmVnaW9uIjogIlJlZ2lvbk9uZSIsICJpbnRlcm5hbFVSTCI6ICJodHRwOi8vMTkyLjE2OC4xNTAuMTI5OjgwODAvdjEvQVVUSF84YzAwOGQ2OGJiZDc0Y2Q4OGRkMDRhNGIzNzcyNTRlNyIsICJpZCI6ICIxOTJkNTQ2MWI5ZTU0NjVmODEwNzQ5NTg4ODZmYmQ5MyIsICJwdW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YGA1UEAxMPd3d3LmV4YW1wbGUuY29tAgEBMAcGBSsOAwIaMA0GCSqGSIb3DQEBAQUABIIBAFJvNW5phkY3O6R3lk6DCNSvjbk56iPqqESJDAfpARv8Iyqnd7vpLIrjKvZwKbVVSSbAuVlum6jfMPe30o0tKXXmteE4UYxWoDIdSZRz86YrYaJEWNWDpvO-1jtR2+UsxBSPrJYDa32xzIvzkZc2vUTNHot1UehlB17hRCeH4yhZYG1BEqaNX8PLnewAMdjAc4Gp4v9SNMrkunjKyPgUVYSqXJZjqRNhsASZd4kyyRdc0nbj-qQ0CSSsdjU6iCEe9lO+CMBjXwN1O0k0TM1gZnnZQ1okQCQTgK7Ya8UcRszyQdg3nojigxiE97ppgGrpR+P-R4v3i+kQ81P+FPByRXY=",
             "tenant": {
                "description": null,
                 "enabled": true,
                 "id": "8c008d68bbd74cd88dd04a4b377254e7",
                 "name": "service"
            }
        },
         "serviceCatalog": [
            {
                "endpoints": [
                    {
                        "adminURL": "http://192.168.150.129:8080",
                         "region": "RegionOne",
                         "internalURL": "http://192.168.150.129:8080/v1/AUTH_8c008d68bbd74cd88dd04a4b377254e7",
                         "id": "192d5461b9e5465f81074958886fbd93",
                         "publicURL": "http://192.168.150.129:8080/v1/AUTH_8c008d68bbd74cd88dd04a4b377254e7"
                    }
                ],
                 "endpoints_links": [
                   
                ],
                 "type": "object-store",
                 "name": "swift"
            },
             {
                "endpoints": [
                    {
                        "adminURL": "http://192.168.150.129:35357/v2.0",
                         "region": "RegionOne",
                         "internalURL": "http://192.168.150.129:5000/v2.0",
                         "id": "71af9dc85f634728b2d4384df36ecac9",
                         "publicURL": "http://192.168.150.129:5000/v2.0"
                    }
                ],
                 "endpoints_links": [
                   
                ],
                 "type": "identity",
                 "name": "keystone"
            }
        ],
         "user": {
            "username": "swift",
             "roles_links": [
               
            ],
             "id": "663a26d5c78b41a19034034762dc5b0b",
             "roles": [
                {
                    "name": "_member_"
                },
                 {
                    "name": "admin"
                }
            ],
             "name": "swift"
        },
         "metadata": {
            "is_admin": 0,
             "roles": [
                "9fe2ff9ee4384b1894a90878d3e92bab",
                 "87fa6e8e51004488aba30020fd9a93dc"
            ]
        }
    }
}

posted @ 2013-07-30 17:18  windlaughing  阅读(2204)  评论(0编辑  收藏  举报