Sha256: b02307591e3d24a30f5977587ff4ca9c9f819e8d1b4d30fb47fdaa5791b9c810
Contents?: true
Size: 1.11 KB
Versions: 5
Compression:
Stored size: 1.11 KB
Contents
class Kamal::Secrets::Adapters::LastPass < Kamal::Secrets::Adapters::Base private def login(account) unless loggedin?(account) `lpass login #{account.shellescape}` raise RuntimeError, "Failed to login to LastPass" unless $?.success? end end def loggedin?(account) `lpass status --color never`.strip == "Logged in as #{account}." end def fetch_secrets(secrets, account:, session:) items = `lpass show #{secrets.map(&:shellescape).join(" ")} --json` raise RuntimeError, "Could not read #{secrets} from LastPass" unless $?.success? items = JSON.parse(items) {}.tap do |results| items.each do |item| results[item["fullname"]] = item["password"] end if (missing_items = secrets - results.keys).any? raise RuntimeError, "Could not find #{missing_items.join(", ")} in LassPass" end end end def check_dependencies! raise RuntimeError, "LastPass CLI is not installed" unless cli_installed? end def cli_installed? `lpass --version 2> /dev/null` $?.success? end end
Version data entries
5 entries across 5 versions & 2 rubygems