Class: Conjur::User

Inherits:
RestClient::Resource
  • Object
show all
Includes:
ActsAsAsset, ActsAsUser
Defined in:
lib/conjur/user.rb

Overview

This class represents a Conjur User.

Instance Method Summary collapse

Methods included from ActsAsUser

#api, #api_key

Methods included from ActsAsRole

#can, #cannot, #role, #role_kind, #roleid

Methods included from ActsAsAsset

#add_member, #remove_member

Methods included from HasAttributes

#attributes, #invalidate, #refresh, #save, #to_json

Methods included from ActsAsResource

#deny, #permit, #resource, #resource_kind, #resourceid

Methods included from HasOwner

#ownerid, #userid

Methods included from Exists

#exists?

Methods included from HasId

#id

Instance Method Details

#loginString

This method is simply an alias for HasId#id. It returns the user's unqualified id, which is referred to as login here because it can be used to login to Conjur.

Returns:

  • (String)

    the login for this user



35
# File 'lib/conjur/user.rb', line 35

def ; id end

#uidnumberFixnum

Note:

This feature requires Conjur server version 4.3 or later.

Get the user's uidnumber, which is used by LDAP and SSH login, among other things.

Permissions

You must have the 'show' permission on the user's resource to call this method

Returns:

  • (Fixnum)

    the uidnumber

Raises:

  • (RestClient::Forbidden)

    if you don't have permission to show the user.



69
70
71
# File 'lib/conjur/user.rb', line 69

def uidnumber
  attributes['uidnumber']
end

#uidnumber=(uidnumber)

Note:

This feature requires Conjur server version 4.3 or later.

This method returns an undefined value.

Set the user's uidnumber, which is used by LDAP and SSH login.

Permissions

You must be a member of the user's role to call this method.

Parameters:

  • uidnumber (Fixnum)

    the new uidnumber

Raises:

  • (RestClient::Conflict)

    if the uidnumber is already in use.



83
84
85
# File 'lib/conjur/user.rb', line 83

def uidnumber= uidnumber
  update uidnumber: uidnumber
end

#update(options)

Note:

This feature requires Conjur server version 4.3 or later.

This method returns an undefined value.

Assign new attributes to the user. Currently, this method only lets you change the :uidnumber attribute.

If a user with the given :uidnumber already exists, this method will raise RestClient::Forbidden, with the response body providing additional details if possible.

Permissions

You must be a member of the user's role to call this method.

Parameters:

  • options (Hash)

    attributes to change

Options Hash (options):

  • :uidnumber (FixNum)

    the new uidnumber for this user. This option must be present.

Raises:

  • (RestClient::Conflict)

    if the uidnumber is already in use

  • (ArgumentError)

    if uidnumber isn't a Fixnum or isn't present in options



53
54
55
56
57
58
# File 'lib/conjur/user.rb', line 53

def update options
  # Currently the server raises a 400 Bad Request if uidnumber is missing, require it here
  raise ArgumentError "options[:uidnumber] is required" unless uidnumber = options[:uidnumber]
  raise ArgumentError, "options[:uidnumber] must be a Fixnum" unless uidnumber.kind_of?(Fixnum)
  self.put(options)
end