Wilma pep 代理和 keystone - 未找到有效的访问令牌
Wilma pep proxy and keystone - valid access token not found
我让 wilma 将有效请求重定向到 orion,但没有消息到达它,因为我总是从 wilma 那里收到 "Access Token not found"。 wilma配置文件中输入的账户是keystone的admin账户。
从 openStack API docs 我使用以下请求请求令牌。
curl -i \
> -H "Content-Type: application/json" \
> -d '
> { "auth": {
> "identity": {
> "methods": ["password"],
> "password": {
> "user": {
> "name": "userAdmin",
> "domain": { "id": "default" },
> "password": "pw"
> }
> }
> }
> }
> }' \
> http://130.206.115.xxx:5000/v3/auth/tokens ; echo
我想我得到了一个有效的令牌,因为使用带有 x-auth-token 的 curl 直接请求 keystone 工作正常。
然后我尝试从我的电脑卷曲
curl --header "X-Auth-Token:$TOKEN" <ipOfWilma>:80/v2/entities
并得到答案:"User token not authorized"。
威尔玛在控制台上报告
[TOKEN] Checking token with IDM...
User access-token not authorized
Auth-token not found in request header
Keystone 报告相同
"GET /v3/access-tokens/90ecf18114164f98b25668b9a940eb44 HTTP/1.1" 404
为什么我在通过 wilma 而不是直接请求时却找不到此访问令牌?
编辑:我也尝试请求域范围的令牌,但收到同样的错误。
好的,我想我明白了。有两件事需要考虑:
Wilma 返回的错误是 Auth-token not found in request header
,这让我觉得您发送的 --header 'X-Auth-Token: <x-auth-token>'
不知何故。确保您的值得到很好的解析(正如我看到您使用的参数)。
您从 Keystone 检索到的令牌是 keystone token
,并不是您需要的。要访问受保护的资源,您需要使用 Oauth-token
。一开始可能有点混乱,但如果你仔细想想,一切都是有道理的。检查 Open Specification 以获得更好的理解。
所以,在这一点上,我假设您已经在 Keyrock 实例中配置了您的 APP,并且您能够检索 client_secret
和 client_id
。现在您有 2 种方法来检索 Fi-ware-Idm wiki:
中的 Oauth 令牌
Authorization Code Grant. You have a simple example here,根据自己的需要配置config.js
即可。
Resource Owner Password Credentials Grant, which is easier to retrieve for simple requests (in my opinion). For this case we have a simple script in bash here。只需确保根据您的要求替换 CLIENT_ID
、CLIENT_SECRET
和 REQUEST
中的主机(或 IP)。然后,只需 运行:
sh auth-token.sh <user-email> <password>
然后您应该能够取回令牌。使用该令牌,如果资源在 Authzforce 中获得授权,一切都应该有效。
最后,如果您喜欢 docker
并想尝试一下,我们有一个使用 docker
和 docker-compose
的解决方法,它使用了您正在使用的通用启动器。例如,您可以在此处找到 PEP Wilma 的文档以及如何 运行 它(非常简单)。
如果您有任何疑问,请告诉我。
我让 wilma 将有效请求重定向到 orion,但没有消息到达它,因为我总是从 wilma 那里收到 "Access Token not found"。 wilma配置文件中输入的账户是keystone的admin账户。 从 openStack API docs 我使用以下请求请求令牌。
curl -i \
> -H "Content-Type: application/json" \
> -d '
> { "auth": {
> "identity": {
> "methods": ["password"],
> "password": {
> "user": {
> "name": "userAdmin",
> "domain": { "id": "default" },
> "password": "pw"
> }
> }
> }
> }
> }' \
> http://130.206.115.xxx:5000/v3/auth/tokens ; echo
我想我得到了一个有效的令牌,因为使用带有 x-auth-token 的 curl 直接请求 keystone 工作正常。
然后我尝试从我的电脑卷曲
curl --header "X-Auth-Token:$TOKEN" <ipOfWilma>:80/v2/entities
并得到答案:"User token not authorized"。 威尔玛在控制台上报告
[TOKEN] Checking token with IDM...
User access-token not authorized
Auth-token not found in request header
Keystone 报告相同
"GET /v3/access-tokens/90ecf18114164f98b25668b9a940eb44 HTTP/1.1" 404
为什么我在通过 wilma 而不是直接请求时却找不到此访问令牌?
编辑:我也尝试请求域范围的令牌,但收到同样的错误。
好的,我想我明白了。有两件事需要考虑:
Wilma 返回的错误是
Auth-token not found in request header
,这让我觉得您发送的--header 'X-Auth-Token: <x-auth-token>'
不知何故。确保您的值得到很好的解析(正如我看到您使用的参数)。您从 Keystone 检索到的令牌是
keystone token
,并不是您需要的。要访问受保护的资源,您需要使用Oauth-token
。一开始可能有点混乱,但如果你仔细想想,一切都是有道理的。检查 Open Specification 以获得更好的理解。
所以,在这一点上,我假设您已经在 Keyrock 实例中配置了您的 APP,并且您能够检索 client_secret
和 client_id
。现在您有 2 种方法来检索 Fi-ware-Idm wiki:
Authorization Code Grant. You have a simple example here,根据自己的需要配置
config.js
即可。Resource Owner Password Credentials Grant, which is easier to retrieve for simple requests (in my opinion). For this case we have a simple script in bash here。只需确保根据您的要求替换
CLIENT_ID
、CLIENT_SECRET
和REQUEST
中的主机(或 IP)。然后,只需 运行:sh auth-token.sh <user-email> <password>
然后您应该能够取回令牌。使用该令牌,如果资源在 Authzforce 中获得授权,一切都应该有效。
最后,如果您喜欢 docker
并想尝试一下,我们有一个使用 docker
和 docker-compose
的解决方法,它使用了您正在使用的通用启动器。例如,您可以在此处找到 PEP Wilma 的文档以及如何 运行 它(非常简单)。
如果您有任何疑问,请告诉我。