<html><head><meta http-equiv="content-type" content="text/html; charset=GB2312"><style>body { line-height: 1.5; }body { font-size: 10.5pt; font-family: 'Microsoft YaHei UI'; color: rgb(0, 0, 0); line-height: 1.5; }</style></head><body>
<div><span></span>您好:</div><div><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'=""> </span><span style="font-family: ''; font-size: 10.5pt; line-height: 1.5; background-color: window;"> 我最近在做Keystone的相关调研,有一个地方不太明白,想请教您。我想要让一个user 加入到 project中,但是在官网没有找到相关API,是我对这两个名称理解有误吗?后来,我找到这个API :</span><span style="color: rgb(85, 85, 85); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif; font-weight: bold; orphans: 2; widows: 2; font-size: 10.5pt; line-height: 1.5; background-color: window;">Assign role to user on project. 这个API有将user加入到project的作用吗? </span><span style="color: rgb(85, 85, 85); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif; orphans: 2; widows: 2; font-size: 10.5pt; line-height: 1.5; background-color: window;">我尝试使用了上面这个API ,并使用下面这个API:</span><span style="color: rgb(85, 85, 85); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif; font-weight: bold; orphans: 2; widows: 2; font-size: 10.5pt; line-height: 1.5; background-color: window;">List projects for user 去</span><span style="color: rgb(85, 85, 85); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif; orphans: 2; widows: 2; font-size: 10.5pt; line-height: 1.5; background-color: window;">检查是否把用户加入了Project。</span></div><div style="orphans: 2; widows: 2; "><font color="#555555" face="-apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen-Sans, Ubuntu, Cantarell, Helvetica Neue, sans-serif"><br></font></div><div style="orphans: 2; widows: 2; "><font color="#555555" face="-apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen-Sans, Ubuntu, Cantarell, Helvetica Neue, sans-serif">过程中使用的TOKEN 是这么获取的:</font></div><div style="orphans: 2; widows: 2; "><span style="font-family: "-apple-system, BlinkMacSystemFont, " segoe="" ui',="" roboto,="" oxygen-sans,="" ubuntu,="" cantarell,="" 'helvetica="" neue',="" sans-serif";="" font-size:="" 14px;="" color:="" rgb(85,="" 85,="" 85);="" background-color:="" rgba(0,="" 0,="" 0);="" font-weight:="" bold;="" font-style:="" normal;text-decoration:="" none;'="">curl -i -X POST\<br> -H "Content-Type: application/json" \<br> -d '<br> { "auth": {<br> "identity": {<br> "methods": ["password"],<br> "password": {<br> "user": {<br> "name": "admin",<br> "domain": { "id": "default" },<br> "password": "0407"<br> }<br> }<br> },<br> "scope": {<br> "project": {<br> "domain": {<br> "name": "Default"<br> },<br> "name": "admin"<br> }<br> }<br> }<br> }' \<br> "http://localhost:5000/v3/auth/tokens" ;</span></div><div style="orphans: 2; widows: 2; "><span style="font-family: "-apple-system, BlinkMacSystemFont, " segoe="" ui',="" roboto,="" oxygen-sans,="" ubuntu,="" cantarell,="" 'helvetica="" neue',="" sans-serif";="" font-size:="" 14px;="" color:="" rgb(85,="" 85,="" 85);="" background-color:="" rgba(0,="" 0,="" 0);="" font-weight:="" bold;="" font-style:="" normal;text-decoration:="" none;'=""><br></span></div><div style="orphans: 2; widows: 2; "><font face="-apple-system, BlinkMacSystemFont, ">这个是用户:</font></div><div style="orphans: 2; widows: 2; "><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'=""><span style="font-family: ''; font-size: 10.5pt; line-height: 1.5; background-color: window;"> </span>{<br> "user": {<br> "name": "xiangsun4",<br> "links": {<br> "self": "http://localhost:5000/v3/users/95df8c5d80ff4f43bd239500048973b3"<br> },<br> "domain_id": "default",<br> "enabled": true,<br> "options": {},<br> "default_project_id": "a44c2e1e6eb247e086e62d81a0573c7b",<br> "id": "95df8c5d80ff4f43bd239500048973b3",<br> "password_expires_at": null<br> }<br> }</span></div><div style="orphans: 2; widows: 2; "><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'=""><br></span></div><div style="orphans: 2; widows: 2; "><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'="">这个是project:</span></div><div style="orphans: 2; widows: 2; "><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'=""><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'="">{<br> "project": {<br> "is_domain": false,<br> "description": "My first project",<br> "links": {<br> "self": "http://localhost:5000/v3/projects/dae552c5d08f4657a2af34bcb39bafd3"<br> },<br> "enabled": true,<br> "id": "dae552c5d08f4657a2af34bcb39bafd3",<br> "parent_id": "default",<br> "domain_id": "default",<br> "name": "project4"<br> }<br> }</span></span></div><div style="orphans: 2; widows: 2; "><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'=""><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'=""><br></span></span></div><div style="orphans: 2; widows: 2; "><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'=""><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'=""><br></span></span></div><div style="orphans: 2; widows: 2; "><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'=""><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'=""><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'=""><b>**这个是role,role中定义了domain_id</b><br> {<br> "role": {<br> <b>"domain_id": "default",</b><br> "id": "aa07402e8bc041e89db3fc4c0fbe98a0",<br> "links": {<br> "self": "http://localhost:5000/v3/roles/aa07402e8bc041e89db3fc4c0fbe98a0"<br> },<br> "name": "noDomainRole2"<br> }<br> }</span></span></span></div>
<div><br></div><div>然后我调用了下面的<span style="font-family: ''; font-size: 10.5pt; line-height: 1.5; background-color: window;"> API尝试把三者捆绑。 </span></div><div><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'=""> curl -i -X PUT \<br> -H "X-Auth-Token: $OS_TOKEN" \<br> "http://localhost:5000/v3/projects/<span style="orphans: 2; widows: 2;">dae552c5d08f4657a2af34bcb39bafd3</span>/users/<span style="orphans: 2; widows: 2;">95df8c5d80ff4f43bd239500048973b3</span>/roles/<span style="orphans: 2; widows: 2;">aa07402e8bc041e89db3fc4c0fbe98a0</span>"</span></div><div><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'=""><br></span></div><div><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'="">接着我调用了下面的API, 查看这个user是否有project:</span></div><div><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'=""><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'="">curl -i -X GET -H "X-Auth-Token: $OS_TOKEN" "http://localhost:5000/v3/users/95df8c5d80ff4f43bd239500048973b3/projects"</span></span></div><div><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'=""><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'=""><br></span></span></div><div><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'=""><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'="">返回的结果是:</span></span></div><div><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'=""><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'=""><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'="">{"links": {"self": "http://localhost:5000/v3/users/95df8c5d80ff4f43bd239500048973b3/projects", "previous": null, "next": null}, "projects": []}</span></span></span></div><div><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'=""><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'=""><br></span></span></div><div><b>由返回看出projects 是空数组。</b></div><div><br></div><div><br></div><div style="font-size: 15px;"><b>但我使用了另外一个role, 这个role和上面role的区别就在于 没有domain_id:</b></div><div><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'="">{<br> "role": {<br> <b> "domain_id": null,</b><br> "id": "1cf7d2e43c814dc8bd7d66e380f6b339",<br> "links": {<br> "self": "http://localhost:5000/v3/roles/1cf7d2e43c814dc8bd7d66e380f6b339"<br> },<br> "name": "noDomainRole1"<br> }<br> }</span></div><div><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'=""><br></span></div><div><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'="">然后再捆绑同一个project-user,再用同样的方式检查, 他的project数组是有值的</span></div><div><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'=""><br></span></div><div style="font-size: 19px;"><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'=""><b>这个是为什么呢??</b></span></div><div style="font-size: 19px;"><br></div><div style="font-size: 19px;"><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'=""><b><br></b></span></div><div>我进一步测试我修改了第一个role数据库中的domain_id,由default修改成了<<null>>,再调用相同的方式检查,他返回的project数组有值,我再由<<null>>修改成了default,返回的project数组又是空的。 </div><div style="font-size: 19px;"><b>这又是为什么呢?捆绑三者的域都是default,为什么会和default_id有关呢?</b></div><div style="font-size: 19px;"><b><br></b></div><div style="font-size: 19px;"><b>麻烦您了,请您帮我解答一下,万分感谢!!!</b></div><div><br></div><hr style="width: 210px; height: 1px;" color="#b5c4df" size="1" align="left">
<div><span><div style="margin: 10px; font-size: 10pt;"><div style="font-size: 24px;"><span style="font-family: 华文行楷;">孙翔</span></div><div style="font-size: 24px;"><br></div></div></span></div>
</body></html>