Ruby on rails 4 如何使用授权用户向具有相同ldap授权的其他项目发出请求?

Ruby on rails 4 如何使用授权用户向具有相同ldap授权的其他项目发出请求?,ruby-on-rails-4,ldap,Ruby On Rails 4,Ldap,我无法向具有相同身份的其他项目发出请求 我已经试着去做了 req.basic_auth curent_user.username, current_user.encrypted_password 但它表示,currnet_用户尚未定义 我试着在项目2中设置 skip_before_filter :authenticate_user!, only: :get_data 它返回的位 {"status":"422","error":"Unprocessable Entity"} 代码是 uri

我无法向具有相同身份的其他项目发出请求

我已经试着去做了

req.basic_auth curent_user.username, current_user.encrypted_password
但它表示,currnet_用户尚未定义

我试着在项目2中设置

skip_before_filter :authenticate_user!, only: :get_data
它返回的位

{"status":"422","error":"Unprocessable Entity"}
代码是

uri = URI(["#{request.protocol}#{request.host_with_port}", 'clients', Rails.configuration.system_client_name, 'project1', 'get_data'].join('/'))
res = nil
Net::HTTP.start(uri.host, uri.port,
  :use_ssl => uri.scheme == 'https'
) do |http|
  req = Net::HTTP::Post.new(uri.request_uri)
  # ??? req.basic_auth curent_user.username, current_user.encrypted_password

  res = http.request(req)
end
data = res.body
项目1

def get_data
  render json: {q: 1}, status: 200
end
两个项目中的gem是相同的

    devise_ldap_authenticatable (0.8.1)
      devise (>= 3.0)
      net-ldap (>= 0.3.1, < 0.6.0)
designe_ldap_authenticable(0.8.1)
设计(>=3.0)
net ldap(>=0.3.1,<0.6.0)
我没有进行身份验证

在项目2中:

skip_before_action :verify_authenticity_token, only: : get_data
skip_before_action :authenticate_user!, only: : get_data
在项目1中:

uri = URI(["#{request.protocol}#{request.host_with_port}", 'clients', Rails.configuration.system_client_name, get_data, 'get_num_of_synonyms'].join('/'))
    res = nil
    Net::HTTP.start(uri.host, uri.port,
      :use_ssl => uri.scheme == 'https'
    ) do |http|
      req = Net::HTTP::Post.new(uri.request_uri, 'Content-Type' => 'application/json')

      res = http.request(req)
    end
我没有做任何授权

在项目2中:

skip_before_action :verify_authenticity_token, only: : get_data
skip_before_action :authenticate_user!, only: : get_data
在项目1中:

uri = URI(["#{request.protocol}#{request.host_with_port}", 'clients', Rails.configuration.system_client_name, get_data, 'get_num_of_synonyms'].join('/'))
    res = nil
    Net::HTTP.start(uri.host, uri.port,
      :use_ssl => uri.scheme == 'https'
    ) do |http|
      req = Net::HTTP::Post.new(uri.request_uri, 'Content-Type' => 'application/json')

      res = http.request(req)
    end