Class: Ruborg::Passbolt
- Inherits:
-
Object
- Object
- Ruborg::Passbolt
- Defined in:
- lib/ruborg/passbolt.rb
Overview
Passbolt CLI integration for password management
Instance Method Summary collapse
- #get_password ⇒ Object
-
#initialize(resource_id: nil, logger: nil) ⇒ Passbolt
constructor
A new instance of Passbolt.
Constructor Details
#initialize(resource_id: nil, logger: nil) ⇒ Passbolt
Returns a new instance of Passbolt.
8 9 10 11 12 |
# File 'lib/ruborg/passbolt.rb', line 8 def initialize(resource_id: nil, logger: nil) @resource_id = resource_id @logger = logger check_passbolt_cli end |
Instance Method Details
#get_password ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ruborg/passbolt.rb', line 14 def get_password raise PassboltError, "Resource ID not configured" unless @resource_id @logger&.info("Retrieving password from Passbolt (resource_id: #{@resource_id})") cmd = ["passbolt", "get", "resource", "--id", @resource_id, "--json"] output, status, error_msg = execute_command(cmd) unless status @logger&.error("Failed to retrieve password from Passbolt for resource #{@resource_id}") error_detail = error_msg ? ": #{error_msg}" : "" raise PassboltError, "Failed to retrieve password from Passbolt#{error_detail}" end @logger&.info("Successfully retrieved password from Passbolt") parse_password(output) end |