OpenStack 的驗證服務有兩個主要功能:json
1. 用戶管理(租戶、用戶、權限)swift
2. Service catalog,管理服務的目錄和它們的endpoint。app
1. Useride
User即用戶,他們表明訪問openstack的人或程序。Users經過認證信息(credentials,如密碼、API Keys等)進行驗證。lua
2. Tenanturl
Tenant即租戶,它是各個服務中的一些能夠訪問的資源集合。在Swift,資源是以tenant爲單位進行劃分的。Users默認的老是綁定到某些tenant上。翻譯
3. Role3d
Role即角色,Roles表明一組用戶能夠訪問的資源權限。Role是在驗證服務定義,可是具體意義由執行操做的服務(好比 swift)解釋。對象
4. Serviceblog
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被從常規的訪問中分離。
六、Token
Token是訪問資源的鑰匙。它是經過Keystone驗證後的返回值,在以後的與其餘服務交互中只須要攜帶Token值便可。每一個Token都有一個有效期,Token只在有效期內是有效的。
一、租戶下,管理着一堆用戶(人,或程序)。
二、每一個用戶都有本身的credentials(憑證)。用戶名+密碼,或者,用戶名+API key,或其餘憑證。
三、用戶在訪問其餘資源(計算、存儲)以前,須要用本身的credential,去請求keystone服務,得到驗證信息(主要是Token信息)和服務信息(服務目錄和它們的endpoint)。
四、用戶拿着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": "MIIGXgYJKoZIhvcNAQcCoIIGTzCCBksCAQExCTAHBgUrDgMCGjCCBLQGCSqGSIb3DQEHAaCCBKUEggSheyJhY2Nlc3MiOiB7InRva2VuIjogeyJpc3N1ZWRfYXQiOiAiMjAxMy0wNy0zMFQwODo0NDoyOC4zMzYxMzkiLCAiZXhwaXJlcyI6ICIyMDEzLTA3LTMxVDA4OjQ0OjI4WiIsICJpZCI6ICJwbGFjZWhvbGRlciIsICJ0ZW5hbnQiOiB7ImRlc2NyaXB0aW9uIjogbnVsbCwgImVuYWJsZWQiOiB0cnVlLCAiaWQiOiAiOGMwMDhkNjhiYmQ3NGNkODhkZDA0YTRiMzc3MjU0ZTciLCAibmFtZSI6ICJzZXJ2aWNlIn19LCAic2VydmljZUNhdGFsb2ciOiBbeyJlbmRwb2ludHMiOiBbeyJhZG1pblVSTCI6ICJodHRwOi8vMTkyLjE2OC4xNTAuMTI5OjgwODAiLCAicmVnaW9uIjogIlJlZ2lvbk9uZSIsICJpbnRlcm5hbFVSTCI6ICJodHRwOi8vMTkyLjE2OC4xNTAuMTI5OjgwODAvdjEvQVVUSF84YzAwOGQ2OGJiZDc0Y2Q4OGRkMDRhNGIzNzcyNTRlNyIsICJpZCI6ICIxOTJkNTQ2MW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gNVBAcTBVVuc2V0MQ4wDAYDVQQKEwVVbnNldDEYMBYGA1UEAxMPd3d3LmV4YW1wbGUuY29tAgEBMAcGBSsOAwIaMA0GCSqGSIb3DQEBAQUABIIBAFJvNW5phkY3O6R3lk6DCNSvjbk56iPqqESJDAfpARv8Iyqnd7vpLIrjKvZwKbVVSSbAuVlum6jfMPe30o0tKXXmteE4UYxWoDIdSZRz86YrYaJEWNWDpvO-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" ] } }}