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, #rotate_api_key, #set_cidr_restrictions

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



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

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.



74
75
76
# File 'lib/conjur/user.rb', line 74

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.



88
89
90
# File 'lib/conjur/user.rb', line 88

def uidnumber= uidnumber
  update uidnumber: uidnumber
end

#update(options)

Note:

Updating uidnumber requires Conjur server version 4.3 or later.

Note:

Updating cidr requires Conjur server version 4.6 or later.

This method returns an undefined value.

Assign new attributes to the user.

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 update the uidnumber. You must have update permission on the user's resource or be the user to update CIDR restrictions.

Parameters:

  • options (Hash)

    attributes to change

Options Hash (options):

  • :uidnumber (FixNum)

    the new uidnumber for this user.

  • :cidr (Array<String, IPAddr>)

    the network restrictions for this user. Requires Conjur server version 4.6 or later

Raises:

  • (RestClient::Conflict)

    if the uidnumber is already in use

  • (ArgumentError)

    if uidnumber or cidr aren't valid



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/conjur/user.rb', line 53

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

  if cidr = options[:cidr]
    set_cidr_restrictions cidr
  end
end