Class: Sailpoint::Config
- Inherits:
-
Object
- Object
- Sailpoint::Config
- Defined in:
- lib/sailpoint/config.rb
Overview
Used for setting API configuration before creating API Requests Configuration can include: username, password, interface, host, url
Class Attribute Summary collapse
-
.host ⇒ String
Used to fetch the host for the API request.
-
.interface ⇒ String
Used for setting if the interface type is Rest || SCIM.
-
.password ⇒ String
Used for fetching the requesting users credentials password (if it has been set).
-
.url(interface = '') ⇒ String
Used for fetching the requesting users entire URL (Host+Interface).
-
.username ⇒ String
Used for fetching credentails username (if it has been set).
Instance Attribute Summary collapse
-
#interface ⇒ Object
Returns the value of attribute interface.
-
#password ⇒ Object
Returns the value of attribute password.
-
#url ⇒ Object
Returns the value of attribute url.
-
#username ⇒ Object
Returns the value of attribute username.
Class Method Summary collapse
-
.auth_header ⇒ String
Used for generating the API BasicAuth Header when creating an API request.
-
.credentials ⇒ String
Used for fetching the API credentials when setting API requests headers.
- .full_host(interface = '') ⇒ Object
-
.hashed_credentials ⇒ String
SailPoints auth requires a Base64 string of (username:password) This is how most BasicAuth authentication methods work.
-
.interface_path ⇒ String
Used for fetching the API interface_path based on the API interface specification.
-
.set_credentials(username, password) ⇒ Object
Used to set the API requests BasicAuth credentails.
-
.trimmed_host ⇒ String
Remove trailing forward slashes from the end of the Host, that way hosts and interfaces can be properly joined => I also did this because you’d get the same results if something supplied
http://example.comorhttps://example.com/.
Class Attribute Details
.host ⇒ String
Used to fetch the host for the API request
41 42 43 44 45 |
# File 'lib/sailpoint/config.rb', line 41 def host return '' if @host.blank? trimmed_host end |
.interface ⇒ String
Used for setting if the interface type is Rest || SCIM
29 30 31 |
# File 'lib/sailpoint/config.rb', line 29 def interface (@interface ||= 'rest') end |
.password ⇒ String
Used for fetching the requesting users credentials password (if it has been set)
68 69 70 |
# File 'lib/sailpoint/config.rb', line 68 def password @password || '' end |
.url(interface = '') ⇒ String
Used for fetching the requesting users entire URL (Host+Interface)
50 51 52 53 54 |
# File 'lib/sailpoint/config.rb', line 50 def url(interface = '') return '' if @host.blank? || @interface.blank? full_host(interface) end |
.username ⇒ String
Used for fetching credentails username (if it has been set)
62 63 64 |
# File 'lib/sailpoint/config.rb', line 62 def username @username || '' end |
Instance Attribute Details
#interface ⇒ Object
Returns the value of attribute interface.
9 10 11 |
# File 'lib/sailpoint/config.rb', line 9 def interface @interface end |
#password ⇒ Object
Returns the value of attribute password.
9 10 11 |
# File 'lib/sailpoint/config.rb', line 9 def password @password end |
#url ⇒ Object
Returns the value of attribute url.
9 10 11 |
# File 'lib/sailpoint/config.rb', line 9 def url @url end |
#username ⇒ Object
Returns the value of attribute username.
9 10 11 |
# File 'lib/sailpoint/config.rb', line 9 def username @username end |
Class Method Details
.auth_header ⇒ String
Used for generating the API BasicAuth Header when creating an API request
98 99 100 101 102 |
# File 'lib/sailpoint/config.rb', line 98 def auth_header return '' if @username.blank? && @password.blank? { 'Authorization' => "Basic #{Sailpoint::Config.hashed_credentials}" } end |
.credentials ⇒ String
Used for fetching the API credentials when setting API requests headers
74 75 76 |
# File 'lib/sailpoint/config.rb', line 74 def credentials { username: @username, password: @password } end |
.full_host(interface = '') ⇒ Object
56 57 58 |
# File 'lib/sailpoint/config.rb', line 56 def full_host(interface = '') interface.blank? ? [trimmed_host, 'identityiq', interface_path].join('/') : [trimmed_host, 'identityiq', interface].join('/') end |
.hashed_credentials ⇒ String
SailPoints auth requires a Base64 string of (username:password) This is how most BasicAuth authentication methods work
90 91 92 93 94 |
# File 'lib/sailpoint/config.rb', line 90 def hashed_credentials return '' if @username.blank? && @password.blank? Base64.encode64("#{@username}:#{@password}").strip end |
.interface_path ⇒ String
Used for fetching the API interface_path based on the API interface specification
35 36 37 |
# File 'lib/sailpoint/config.rb', line 35 def interface_path (@interface == 'scim' ? 'scim' : 'rest') end |
.set_credentials(username, password) ⇒ Object
Used to set the API requests BasicAuth credentails
22 23 24 25 |
# File 'lib/sailpoint/config.rb', line 22 def set_credentials(username, password) @username = username unless username.nil? @password = password unless password.nil? end |
.trimmed_host ⇒ String
Remove trailing forward slashes from the end of the Host, that way hosts and interfaces can be properly joined
> I also did this because you’d get the same results if something supplied http://example.com or https://example.com/
81 82 83 84 85 |
# File 'lib/sailpoint/config.rb', line 81 def trimmed_host return '' if @host.blank? @host.strip.gsub!(%r{\/?++$}, '') end |