Sha256: fdfa2d67b6c3e0052b453419f1bd46972fca3da3253eeffd00c1c435365b4ee4

Contents?: true

Size: 1.18 KB

Versions: 28

Compression:

Stored size: 1.18 KB

Contents

module Ridley
  # @example listing all users
  #   conn = Ridley.new(...)
  #   conn.user.all #=> [
  #     #<Ridley::UserObject chef_id:'admin'>
  #   ]
  class UserResource < Ridley::Resource
    set_resource_path "users"
    represented_by Ridley::UserObject

    # Retrieves a user from the remote connection matching the given chef_id
    # and regenerates its private key. An instance of the updated object will
    # be returned and will have a value set for the 'private_key' accessor.
    #
    # @param [String, #chef_id] chef_user
    #
    # @raise [Errors::ResourceNotFound]
    #   if a user with the given chef_id is not found
    #
    # @return [Ridley::UserObject]
    def regenerate_key(chef_user)
      unless chef_user = find(chef_user)
        abort Errors::ResourceNotFound.new("user '#{chef_user}' not found")
      end

      chef_user.private_key = true
      update(chef_user)
    end

    def authenticate(username, password)
      resp = request(:post, '/authenticate_user', {'name' => username, 'password' => password}.to_json)
      abort("Username mismatch: sent #{username}, received #{resp['name']}") unless resp['name'] == username
      resp['verified']
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
ridley-5.1.1 lib/ridley/resources/user_resource.rb
ridley-5.1.0 lib/ridley/resources/user_resource.rb
ridley-5.0.0 lib/ridley/resources/user_resource.rb
ridley-4.6.1 lib/ridley/resources/user_resource.rb
ridley-4.6.0 lib/ridley/resources/user_resource.rb
ridley-4.5.1 lib/ridley/resources/user_resource.rb
ridley-4.5.0 lib/ridley/resources/user_resource.rb
ridley-4.4.3 lib/ridley/resources/user_resource.rb
ridley-4.4.2 lib/ridley/resources/user_resource.rb
ridley-4.4.1 lib/ridley/resources/user_resource.rb
ridley-4.4.0 lib/ridley/resources/user_resource.rb
ridley-4.3.2 lib/ridley/resources/user_resource.rb
ridley-4.3.1 lib/ridley/resources/user_resource.rb
ridley-4.3.0 lib/ridley/resources/user_resource.rb
ridley-4.2.0 lib/ridley/resources/user_resource.rb
ridley-4.1.2 lib/ridley/resources/user_resource.rb
ridley-4.1.1 lib/ridley/resources/user_resource.rb
ridley-4.1.0 lib/ridley/resources/user_resource.rb
ridley-4.0.0 lib/ridley/resources/user_resource.rb
ridley-3.1.0 lib/ridley/resources/user_resource.rb