fog-openstack您提出的请求需要身份验证

时间:2017-10-01 18:15:35

标签: ruby-on-rails authentication openstack fog object-storage

我收到了这个错误:

Expected([201]) <=> Actual(401 Unauthorized) excon.error.response :body => "{\"error\": {\"message\": \"The request you have made requires authentication.\", \"code\": 401, \"title\": \"Unauthorized\"}}" :cookies => [ ] :headers => { "Cache-Control" => "no-cache, no-store, must-revalidate" "Content-Length" => "114" "Content-Security-Policy" => "default-src 'self'" "Content-Type" => "application/json" "Date" => "Sun, 01 Oct 2017 18:02:00 GMT" "Expires" => "0" "Pragma" => "no-cache" "Server" => "Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips mod_wsgi/3.4 Python/2.7.5" "Strict-Transport-Security" => "max-age=31536000" "Vary" => "X-Auth-Token" "WWW-Authenticate" => "Keystone uri=\"https://identity.open.softlayer.com\"" "X-Content-Type-Options" => "nosniff" "X-XSS-Protection" => "0" "x-openstack-request-id" => "req-2bef9760-51da-41d5-9c0f-a5fd6815ebae" } :host => "identity.open.softlayer.com" :local_address => "192.168.1.105" :local_port => 59391 :path => "/v3/auth/tokens" :port => 443 :reason_phrase => "Unauthorized" :remote_ip => "184.173.131.10" :status => 401 :status_line => "HTTP/1.1 401 Unauthorized\r\n"

这就是追踪:

excon (0.59.0) lib/excon/middlewares/expects.rb:7:in `response_call'
excon (0.59.0) lib/excon/middlewares/response_parser.rb:9:in `response_call'
excon (0.59.0) lib/excon/connection.rb:389:in `response'
excon (0.59.0) lib/excon/connection.rb:253:in `request'
fog-core (1.45.0) lib/fog/core/connection.rb:81:in `request'
C:/Ruby24/lib/ruby/gems/2.4.0/bundler/gems/fog-openstack-3d5f4ea27a41/lib/fog/openstack.rb:527:in `retrieve_tokens_v3'
C:/Ruby24/lib/ruby/gems/2.4.0/bundler/gems/fog-openstack-3d5f4ea27a41/lib/fog/openstack.rb:275:in `authenticate_v3'
C:/Ruby24/lib/ruby/gems/2.4.0/bundler/gems/fog-openstack-3d5f4ea27a41/lib/fog/openstack.rb:152:in `authenticate'
C:/Ruby24/lib/ruby/gems/2.4.0/bundler/gems/fog-openstack-3d5f4ea27a41/lib/fog/openstack/core.rb:182:in `authenticate'
C:/Ruby24/lib/ruby/gems/2.4.0/bundler/gems/fog-openstack-3d5f4ea27a41/lib/fog/storage/openstack.rb:98:in `initialize'

我看了一下here,试着弄清楚它可能缺少什么来验证,但我找不到它。

此卷曲有效curl -i -H "Content-Type: application/json" -d @bm.json https://identity.open.softlayer.com/v3/auth/tokens

bm.json的位置:

{
   "auth": {
       "identity": {
           "methods": [
               "password"
           ],
         "password": {
               "user": {
                   "id": "1a5...",
                 "password": "O_C..."
             }
           }
       },
     "scope": {
           "project": {
               "id": "b71..."
         }
       }
   }
}

所以发送它应该足够了:

openstack_auth_url:    "https://identity.open.softlayer.com/v3/auth/tokens",
openstack_api_key:      "O_C...",
openstack_userid:     "1a5...",
openstack_project_id:  "b71...",

我错过了什么?

1 个答案:

答案 0 :(得分:0)

由于您使用的是v3,因此他们的文档建议设置:

@connection_params = {
    openstack_auth_url:     "http://devstack.test:5000/v3/auth/tokens",
    openstack_username:     "admin",
    openstack_api_key:      "password",
    openstack_project_name: "admin",
    openstack_domain_id:    "default"
 }   

我会使用username而不是userid,project_name而不是project_id再次测试它,并指定domain_id。身份验证信息应该在您的服务凭据中。