Authenticate a user with the given username
and
password
.
@note Requires Enterprise Chef
@example Authenticate a user
User.authenticate(username: 'user', password: 'pass') #=> { "status" => "linked", "user" => { ... } }
@param [Hash] options
the list of options to authenticate with
@option options [String] username
the username to authenticate with
@option options [String] password
the plain-text password to authenticate with
@return [Hash]
the parsed JSON response from the server
# File lib/chef-api/resources/user.rb, line 77 def authenticate(options = {}) connection.post('/authenticate_user', options) end
@see Base.each
# File lib/chef-api/resources/user.rb, line 35 def each(prefix = {}, &block) users = collection(prefix) # HEC/EC returns a slightly different response than OSC/CZ if users.is_a?(Array) users.each do |info| name = URI.escape(info['user']['username']) response = connection.get("/users/#{name}") result = from_json(response, prefix) block.call(result) if block end else users.each do |_, path| response = connection.get(path) result = from_json(response, prefix) block.call(result) if block end end end