Class: RightScale::LoginPolicy
- Includes:
- Serializable
- Defined in:
- lib/right_agent/core_payload_types/login_policy.rb
Overview
List of authorized users for Managed Login feature
Constant Summary collapse
- PUBLIC_KEY_REGEXP =
/(.*)?(ssh-[a-z]{1,3})\s+(\S+)\s*(.*)?$/
Instance Attribute Summary collapse
-
#audit_id ⇒ Object
Returns the value of attribute audit_id.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#exclusive ⇒ Object
Returns the value of attribute exclusive.
-
#users ⇒ Object
Returns the value of attribute users.
Class Method Summary collapse
-
.parse_public_key(str) ⇒ Object
Utility method to parse an SSH2-format public key and return a 4-tuple consisting of its constituent parts: * leading comment (optional) * algorithm (ssh-rsa or ssh-dsa) * public key material, as a base64 string * trailing comment or email (optional).
Instance Method Summary collapse
-
#fingerprint ⇒ Object
Compute a cryptographic hash of the information in this policy; helps callers compare two policies to see if they are equivalent.
-
#initialize(*args) ⇒ LoginPolicy
constructor
Initialize fields from given arguments.
-
#serialized_members ⇒ Object
Array of serialized fields given to constructor.
Methods included from Serializable
Constructor Details
#initialize(*args) ⇒ LoginPolicy
Initialize fields from given arguments
37 38 39 40 41 42 |
# File 'lib/right_agent/core_payload_types/login_policy.rb', line 37 def initialize(*args) @audit_id = args[0] @created_at = Time.at( (args[1]||Time.now).to_i ) @exclusive = args[2] || false @users = args[3] || [] end |
Instance Attribute Details
#audit_id ⇒ Object
Returns the value of attribute audit_id.
34 35 36 |
# File 'lib/right_agent/core_payload_types/login_policy.rb', line 34 def audit_id @audit_id end |
#created_at ⇒ Object
Returns the value of attribute created_at.
34 35 36 |
# File 'lib/right_agent/core_payload_types/login_policy.rb', line 34 def created_at @created_at end |
#exclusive ⇒ Object
Returns the value of attribute exclusive.
34 35 36 |
# File 'lib/right_agent/core_payload_types/login_policy.rb', line 34 def exclusive @exclusive end |
#users ⇒ Object
Returns the value of attribute users.
34 35 36 |
# File 'lib/right_agent/core_payload_types/login_policy.rb', line 34 def users @users end |
Class Method Details
.parse_public_key(str) ⇒ Object
Utility method to parse an SSH2-format public key and return a 4-tuple consisting of its constituent parts:
* leading comment (optional)
* algorithm (ssh-rsa or ssh-dsa)
* public key material, as a base64 string
* trailing comment or email (optional)
Parameters
- str(String)
-
the unparsed public key
Return
- components (Array|nil)
-
a 4-tuple of key components, or nil if the key was not a valid public key
86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/right_agent/core_payload_types/login_policy.rb', line 86 def self.parse_public_key(str) match = PUBLIC_KEY_REGEXP.match(str) if match #Return a nice array of strings with no leading/trailing whitespace, and empty #strings transformed into nil return match[1..4].map { |x| x.strip! ; x.empty? ? nil : x } else return nil end end |
Instance Method Details
#fingerprint ⇒ Object
Compute a cryptographic hash of the information in this policy; helps callers compare two policies to see if they are equivalent.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/right_agent/core_payload_types/login_policy.rb', line 52 def fingerprint h = Digest::SHA2.new h << (self.exclusive ? 'true' : 'false') users = self.users.sort { |a, b| a.uuid <=> b.uuid } users.each do |u| h << format(",(%d,%s,%s,%d,%s", u.uuid, u.common_name, (u.superuser ? 'true' : 'false'), (u.expires_at ? u.expires_at.to_i : 0), u.username) u.public_key_fingerprints.each do |fp| h << "," << fp end h << ')' end h.hexdigest end |
#serialized_members ⇒ Object
Array of serialized fields given to constructor
45 46 47 |
# File 'lib/right_agent/core_payload_types/login_policy.rb', line 45 def serialized_members [ @audit_id, @created_at.to_i, @exclusive, @users ] end |